task not relinquishing scheduler busy waiting..

Joel Sherrill joel.sherrill at oarcorp.com
Mon Aug 31 16:21:15 UTC 2015



On 8/31/2015 4:04 AM, Chan Kim wrote:
>
>> Provided task 1 and 3 have the same priority, then you can use a yield (e.g.
>> rtems_task_wake_after(RTEMS_YIELD_PROCESSOR)) in the busy waiting
>> task to give other tasks of the same priority a chance to execute.
> Dr. Sebastian,
> Thank you very much for the reply.
> That's a good information(I didn't know yield is for same priority) . I tried using yield but my thread 3 would actually start.
> In my case, Init is of prirotiy 1, thread 3 is also priority 1. Can you give me another advice on this?
> sorry for asking questions not reading the documents much. (I'll switch to using event)

Although the task/thread scheduling can appear complex, it follows
a few simple rules. By default, the highest priority ready thread
will continue to execute until it blocks, yields, or is preempted
by a higher priority thread.

Your use of a spin wait didn't let any other thread run.

Sebastian's suggestion to add a yield forces a round-robin of threads
of equal priority. If you have multiple threads at the same priority,
it could switch to another thread before getting to the one that services
the device.

His suggestion of using events or condition variables would let the
device servicing thread block until something needs to be done. The
interrupt service routine would send an event or signal the condition.
This will unblock the device servicing thread and it will begin to
compete for CPU time based on the priority rules mentioned above.

Without more details, I would tend to want to make the device servicing
thread block as Sebastian suggested but also make it higher priority
than other threads so will preempt their computations and service the
device with less latency. If it executes quickly and waits for the next
hardware "alert", then the lower priority threads will get to run again
and all should behave well.

-joel

> Chan
>
>
>
>
> 보낸 사람 : "Sebastian Huber" <sebastian.huber at embedded-brains.de>
> 보낸 날짜 : 2015-08-31 17:52:52 ( +09:00 )
> 받는 사람 : 김찬 <ckim at etri.re.kr>, users at rtems.org <users at rtems.org>
> 참조 :
> 제목 : Re: task not relinquishing scheduler busy waiting..
>
>
>
> On 31/08/15 10:28, Chan Kim wrote:
>> But I realized rtems_task_start function only makes the thread in 'READY' state, but not actaully executes it.
>> How do I make task 3 get a chance to run (take scheduler) when task 1 is busy waiting? should I set a scheduler algorithm?
>
> Provided task 1 and 3 have the same priority, then you can use a yield
> (e.g. rtems_task_wake_after(RTEMS_YIELD_PROCESSOR)) in the busy waiting
> task to give other tasks of the same priority a chance to execute.
>

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        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