richard_damon wrote on Friday, September 23, 2016:
When a task calls taskYIELD(), the current task is moved to the back of the ready queue of its current priority, and then the schedule finds the highest priority task that is ready and starts it. That might be the task that called taskYIELD() if there are no other ready task of the same (or possible higher) priority available.
When you have FreeRTOS running with Preemption turned on (which I would think is normal) then every timer tick, the system effectively does a taskYIELD() for the currently running task (unless the scheduler has been disabled) which says that if another ready task exists of the same prioirty, they will trade execution back and forth each timer tick. A lower priority task will only get a chance to execute if all the higher priority tasks are blocked waiting on something (time, a queue, a semaphore, etc). If a higher priority task becomes ready, and preemption is on, then the current task will be suspended and the higher task will procceed.
With preemption turned on, the fundamental rule is that the running task will always be the highest priority task that is ready, and multiple ready tasks of the same priority will execute round robin, switching every timer tick.
With preemption off, a higher priority task or same priority task will need to wait for the current task to yield, letting the scheduler find the new highest priority task.
One key thing to remember, is that, except for priority 0 tasks (IDLE priority) all tasks should be blocking for something at times or the lower priority tasks will get starved for time. And prioriry 0 tasks should either yield at times or you need to have preemption turned on.