Scheduling logic


I am reading the Tutorial Mastering the FreeRTOS Real Timer Kernel written by Richard Barry. I got one question regarding the scheduling algorithm.
In the example in the attached picture, Figure 29 in the book, I don’t understand how the task2 is selected in the first red circle and how the idle task is selected in the second red circle. What is the logic behind?


Since at the first Red Circle, the highest priority task that is ready is at the idle priority, the next ordering is by longest since last run. This comes because when a task is switched away from, it gets put at the back of the list for its level, and tasks are taken from the front of the list.

Ok, my understanding is that for the task switch in the first red circle, Task2 is the task ready to run at the highest priority at that moment. For the task switch in the second red circle, because Task2 was just switched out and idle task in the front of the ready-to-run list, the idle task gets to run. Is my understanding on the logic right?

Yes, that understanding is right.

1 Like