multithreadingvxworks

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

  • A higher priority task will always run, if it is ready, and if you haven't called taskLock() or intLock() etc, so you dont need to taskDelay() to let higher priority tasks run.

    taskDelay(0) will place the current task at the back of the ready queue for that priority level. If it is the only task at that priority, it will be immediately rescheduled regardless of the presence of lower priority tasks

    taskDelay(n>0) will place the current task at the back of the ready queue, for that priority, and it will not be rescheduled for n ticks. This will allow any ready tasks of lower priority to run.

    The parameter to taskDelay() is ticks, not ms. The length of this can be determined based on the system clk rate (which you set by sysClkRateSet(), and read by sysClkRateGet() ). 1 tick might equal 1ms, but only if the system clk rate is 1000. Which it probably wont be. The default rate is 60, which gives a 16ms tick, but this is normally overridden either statically in the kernel config, or dynamically by calling sysClkRateSet()

    NOTE: This system clock is not the same as the CPU freq.