Help: RTEMS Threads, Preemptation and Time slicing...

Joel Sherrill <> joel.sherrill at
Thu Oct 28 11:24:42 UTC 2004

Ian Caddy wrote:
> Hi Alex,
> If your threads are the same priority, pre-emption will not cause one of 
> them to stop, as it will only pre-empt for HIGHER priority threads.
> In this case, you will need to configure these threads for round-robbin 
> (or timeslicing) to achieve what you are asking.
> In saying that though, your system design should never, in practise, 
> consist of tasks that are continuously running as no other task of a 
> lower priority level will ever get to run in this sort of system.  A 
> normal system design will have tasks waiting on things from other tasks, 
> or if not, sleeps that allow the task to yield to lower priority tasks.

I find that often people have threads that either execute much quicker
then the timeslicing quantum or have no scheduling points so unless 
timeslicing is enabled, there is no switching.

Unless you configure the system differently, the timeslice quantum is 10 
milliseconds which is a LOT of CPU cycles on most modern CPUs.

Tasking Design Rule: Find ways for your tasks to naturally block so they
spent most of their life blocked.


> I hope this helps.
> regards,
> Ian Caddy
> Alex wrote:
>> Hi all,
>> I am making little rtems programs involving threads and the POSIX API.
>> I want to create a program that launchs 2 threads via posix calls. 
>> Then I want to split the processor attent to both threads, i mean, 
>> both threads must execute in "parallel" and not to
>> wait one from another...
>> The RTEMS manual says the scheduler look to the different taks in this 
>> order:
>> Priority, preemptation (when activated) and then time slicing (when 
>> activated), right?
>> So, in the rtems program I launch the 2 extra threads with equal 
>> priority, priority 1! For each thread, including the main thread I 
>> turn on the preemptation and time slicing, but the
>> second extra thread only starts execution when the first extra thread 
>> finishs its execution.
>> I cant understand why... :-(
>> Note: If I use a, for example, the sleep() instruction in the body of 
>> the thread, the processor
>> is switch to the other extra thread in a good way, but if i dont use 
>> functions that transfer the
>> execution to other threads, the processor is never switched to other 
>> threads...
>> Can you help me? How to execute the 2 extra threads at the same time 
>> while the main thread is waiting for the 2 extra threads?
>> by the way, is there any way to turn on preemptation and time slicing 
>> using only posix api?

Joel Sherrill, Ph.D.             Director of Research & Development
joel at                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985

More information about the users mailing list