taskYIELD and task slot length optimization

alsaleem wrote on Monday, April 10, 2017:

I have several tasks of same priority. Each time slot is 10msec (ticks is 100Hz).

If a task needs only 6msec (of 10msec). I would like to give rest of time to other tasks instead of waiting next tick (assuming no active high priority task take over on next tick).

As per the maual, taskYIELD will cause OS to switch to other tasks. The next task will only have 4msec of work before next context switch because of SysTick.

Assuming above is correct,
(1) Is there a way to make OS not to context switch on next tick?

(2) If a high priority task wants to allow lower priority tasks to do some work until next tick, will vTaskDelayUntil(&var, 1) block running task immediately and allow lower priority tasks do work until next tick?


richard_damon wrote on Monday, April 10, 2017:

  1. If you disable Time Slicing then tasks of the same priority will not rotate on ticks, but only when yeilding or blocking.
  2. If you have Preemption enabled, then the higher priority task will startup as soon as it is ready (which if it is doing a delay, will be on the timer tick).

One note, if you really want to delay till the next timer tick, use vTaskDelay(1), vTaskDelayUntil(&var, 1) will only delay if the task has ‘caught up’ to the tick counter.

alsaleem wrote on Monday, April 10, 2017:

for (1) I am working on preemption. Assuming no higher priority tasks.

So, will taskYIELD allow next (same priority) task to run until next tick or for whole time slice?


rtel wrote on Monday, April 10, 2017:

Until the next tick.

alsaleem wrote on Tuesday, April 11, 2017:

thanks. that is short and clear answer.