3 ms·
It's for avoiding to halt the CPU when there are other pending tasks ready to run. When the idle task is the only task running, it halts the CPU to save power.
by ww520 12y ago
It's for avoiding to halt the CPU when there are other pending tasks ready to run.
When the idle task is the only task running, it halts the CPU to save power. When the scheduling timer interrupt fires, it wakes up the CPU and calls the scheduler to schedule tasks. If there are other tasks ready to run, the idle task is swapped out to let another task to run but it is still in the ready state. Depending on the scheduling algorithm, the idle task might get picked to run again before other ready tasks. In that case, it should not halt the CPU but rather just busy-loops the rest of the quantum. At that time, the timer interrupt fires and schedules another ready task to run right the way without needing to wake up the CPU.