3 ms·
Note that this seems to be about not waking up the CPU (by timer ticks) more frequently, to allow it to go into a deeper sleep --- AFAIK the actual "idle loop"
by userbinator 8y ago
Note that this seems to be about not waking up the CPU (by timer ticks) more frequently, to allow it to go into a deeper sleep --- AFAIK the actual "idle loop" just executes the HLT instruction, which puts the CPU in a "wait for interrupt" state, and for newer CPUs they go into successively lower power states the longer they're halted.
This reminds me that earlier operating systems like DOS and Win9x kept the CPU in a busy polling loop when idle --- which was great for responsiveness, but not power consumption nor heat; applications like http://www.benchtest.com/rain.html http://www.benchtest.com/rain.html soon appeared, which replaced the idle loop with an actual HLT loop and actually had a noticeable effect. The DOS version is at https://maribu.home.xs4all.nl/zeurkous/download/mirror/dosidle.html https://maribu.home.xs4all.nl/zeurkous/download/mirror/dosid...
- mjg59 8y agoIt's more complicated than that these days. Rather than HLT, you call MWAIT with an argument that corresponds to the C state that you want to enter - the OS has a better idea than the CPU of how long it's going to be asleep (basically what this article is about), so it can tell the CPU to enter a deeper state. The CPU may make an executive decision based on its own needs to enter a different state (potentially even a deeper one), but it's largely still up to the OS to choose rather than the CPU entering progressively deeper states.