'how can a vxworks task let all other lesser priority tasks run for a single multitasking cycle?
how can vxworks task yield the CPU to lower priority tasks for minimumal amount of time?
Is there a method that lets a task give up the CPU for less than 1ms?
The only method that I know of to let other lower priority tasks run is taskDelay(n), where n>=1.
I have always assumed that taskDelay(0) let's all other tasks of equal or greater priority run.
taskDelay(1) lets all lower priority pending tasks run for up to 1ms.
Solution 1:[1]
There are certain events in VxWorks that force the scheduler to run, for instance, each semGive(), each system clock tick, and taskDelay(). The argument for taskDelay() is ticks of the system clock. sysClkRateGet() will return the rate of your system clock.
For example if sysClkRateGet() returns 10, then each clock tick is 100 ms. So if you call taskDelay(1), then that will tell your task to sleep until the next system tick. However this doesn't guarantee a 100 ms sleep, but instead a sleep of up to 100 ms or as little as 0 ms if the next clock tick is imminent. If you call taskDelay(2), then your task will sleep until the next clock tick (some time between 0 and 100 ms) plus the following clock tick (guaranteed to be 100 ms) - resulting in a total delay of between 100 ms and 200 ms.
Timing in VxWorks has alot of consideration and I hope this helps explain some of the details.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | gjcamann |
