I understand what the idle loop *does*; it scans the interrupt queue for inputs and waits for a running process to request operating system time….but what does the idle loop actually *do* when running?
I mean, on a four-core system are all four cores still running full-bore (whatever full-bore means for a particular system, whether it’s running at max or in a stepped down, lower-power mode) parsing a never-ending queue of NOOPs interspersed with periodic queue checks or does the processor actually spin-down (so to speak) and only wake every few milliseconds or what actually happens there?
1. Cores have variables levels of operating capacity. So no, without significant external loads, the cores aren’t going “full bore”.
2. Some modern processors win actually spin down cores that are not very active. It has these optimisations like you mention. Where it checks once ever few microseconds.
3. Short of that, yes. The CPU stays in a never-ending noop loop.
It does nothing.
Most CPU architectures these days come with some form of halt instruction, x86 has HLT, ARM has WFI (wait for interrupt), and if that instruction is issued then the CPU stops executing instructions until the next interrupt comes in, usually being in some kind of low power state.
>only wake every few milliseconds
Just to be clear this is also an interrupt, prior to halting the OS will setup a timer interrupt which will wake it before resuming execution.
Of course its preferable that this doesn’t happen all that often and the OS is responsible for downclocking the CPU if it gets into idle for too long.