3 ms·
> it schedules an "idle thread" that spends its time slice throttling down the CPU Specifically (AFAIK, at least back then) on x86 the kernel schedules an inte
by lloeki 6y ago
> it schedules an "idle thread" that spends its time slice throttling down the CPU
Specifically (AFAIK, at least back then) on x86 the kernel schedules an interrupt and sends a single HLT[0] instruction, and only wakes up when the interrupt triggers. A smartly set up interrupt would have the CPU wake up only as needed for what is required to unblock the pending blocked operations.
Smarter schedulers would go as far as coalescing active events together to rush to idle yet wake up less often, and spend as much time down as possible in increasingly deeper C-states[1].
Back in the day some kernels would loop over NOP[1] instructions, so the CPU would effectively never sleep!
[0]: https://en.wikipedia.org/wiki/HLT_(x86_instruction) https://en.wikipedia.org/wiki/HLT_(x86_instruction)
[1]: https://gist.github.com/wmealing/2dd2b543c4d3cff6cab7 https://gist.github.com/wmealing/2dd2b543c4d3cff6cab7
[2]: https://en.wikipedia.org/wiki/NOP_(code) https://en.wikipedia.org/wiki/NOP_(code)