RTEMS TIME SLICING help

Joel Sherrill joel.sherrill at oarcorp.com
Fri Apr 27 14:45:28 UTC 2007


Ajay S. Nair wrote:
> Hi Joel,
>
> I am using RTEMS 4.6.2. I am running it on a Redhat Linux machine.
> I am using C programs. I am able to do a manual round robin.
> But I would like to get the scheduler to do the timeslicing of tasks for me.
>
> 1. I am unable to get the time slicing option to work in RTEMS.
> I have put the code below:
> rtems_task_create(name1,1,RTEMS_MINIMUM_STACK_SIZE,RTEMS_TIMESLICE |
> RTEMS_PREEMPT,RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL, &tid1);
>
>   
That looks correct.  Timeslicing only applies if you have multiple tasks
at the same priority which are consuming CPU time over the configured
timeslice quantum.  Then RTEMS will round-robin between that set of
tasks.  If you have a higher priority task in the mix and it runs, then the
lower priority task it interrupts will get a fresh timeslice when it runs
again.

Also you did not specify CONFIGURE_TICKS_PER_TIMESLICE
so you get the default of 50.

Also I don't think a clock tick value of 10 microseconds is achievable 
in real
life on any common hardware.  That says that you will be getting an 
interrupt
every 10 microseconds.  Depending on your CPU that could be as few as
every 100 instructions.  I usually use 1 millisecond (e.g. 1000 
microseconds)
until I have good reason to tune it up or down.

I also assume you called rtems_task_start. :)

> Below I have added the configuration file:
> #include <rtems.h>
>
> rtems_task Init(rtems_task_argument ignored);
> rtems_task user_SS(rtems_task_argument ignored); /*My first task*/
> rtems_task user_BC(rtems_task_argument ignored); /* My second task*/
>
> #include <bsp.h>
> #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
> #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
> #define CONFIGURE_MICROSECONDS_PER_TICK 10
> #define CONFIGURE_MAXIMUM_TASKS 4
> #define CONFIGURE_MAXIMUM_POSIX_MUTEXES 6
> #define CONFIGURE_INIT_TASK_NAME rtems_build_name('E','X','A','M')
> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> #define CONFIGURE_INIT
> #include <confdefs.h>
>
>
> 2. Also why do we need to specify the following?
>
>  name1 = rtems_build_name('A','P','P','1');
>
>   
Classic API task names are 32-bit integers.  This puts 4 ASCII 
characters into
that 32-bit value.
> 3. What is the relation between name1, tid1 and APP1?
>
>   
tid1 is the RTEMS ID/Handle for the task you created.  See
http://www.rtems.org/onlinedocs/releases/rtemsdocs-4.7.1/share/rtems/html/c_user/c_user00016.html

for an explanation of Classic API names and Ids.
> 4.What is the purpose of the line below?
> #define CONFIGURE_INIT_TASK_NAME rtems_build_name('E','X','A','M')
>
>   
The Init task is just a task and this makes it have a name.

> Please tell me what I am doing wrong.
>   
--joel

> thank you.
> Regards,
> Ajay S.
> Graduate Student
> U of Arizona
>
>   




More information about the users mailing list