kamen at penev.net
Wed Jun 4 00:17:12 UTC 2003
Chris Johns wrote:
> Angelo Fraietta wrote:
>> Is there a way to use timeslices so a task never gets all cpu usage?
> The classic API has a timeslice option. I am not sure about the POSIX
> or ITRON APIs.
The POSIX API provides a richer selection of timeslicing behaviors than
the classic API. The difference is in what happens after a timesliced
task gets preempted by a higher-priority task before exhausting its
timeslice and later regains control. The only behavior available through
the classic API is that the timeslice of this task gets reset to the
initial value. With the Posix API, in addition to this behavior you can
also specify that the task should resume with what's left of its
This was crucial in my application. I have 5 low-priority tasks that I
want to round-robin with a timeslice of 40ms and a high-priority,
high-frequency(8kHz) task. I set this up with the classic API, but to my
surprise, only one of the 5 lo-priority tasks was ever getting any CPU
(besides the 8kHz task, of course).
What puzzled me even more was that the 5 low-priority tasks would
happily work together, as long as the 8kHz task was not running. What
was happening was that one of the 5 was getting preempted by the 8kHz
task and then when it got back control its clock budget was being reset
back to 40ms!!! It never ran out of time.
I switched to the Posix API for creating the 5 tasks, which allowed me
to modify the timeslicing behavior, and now everything is fine.
More information about the users