Merge pull request #789 from junbo42/linux-timers-3-fix

cpu_idle_loop logical in book is wrong
pull/800/head^2
0xAX 2 years ago committed by GitHub
commit 5f76b7e874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,6 +62,7 @@ static void cpu_idle_loop(void)
...
schedule_preempt_disabled();
}
}
```
Of course, we will not consider full implementation of the `cpu_idle_loop` function and details of the `idle` state in this part, because it is not related to our topic. But there is one interesting moment for us. We know that the processor can execute only one task in one time. How does the Linux kernel decide to reschedule and stop `idle` process if the processor executes infinite loop in the `cpu_idle_loop`? The answer is system timer interrupts. When an interrupt occurs, the processor stops the `idle` thread and transfers control to an interrupt handler. After the system timer interrupt handler will be handled, the `need_resched` will return true and the Linux kernel will stop `idle` process and will transfer control to the current runnable task. But handling of the system timer interrupts is not effective for [power management](https://en.wikipedia.org/wiki/Power_management), because if a processor is in `idle` state, there is little point in sending it a system timer interrupt.

@ -134,5 +134,6 @@ Thank you to all contributors:
* [Yuxin Wu](https://github.com/chaffz)
* [Biao Ding](https://github.com/SmallPond)
* [Arfy slowy](https://github.com/slowy07)
* [Junbo Jiang](https://github.com/junbo42)
* [Dexter Plameras](https://github.com/dexterp)
* [Jun Duan](https://github.com/waltforme)

Loading…
Cancel
Save