What Is The CPU Doing In Its Idle State?
You know when you leave your laptop on for hours without even using it and yet it drains the battery? You blame the CPU since apparently is not even doing anything, instead enjoying its time off. But for the techies out there, you all know that for the CPU, doing nothing also is doing something.
It is routine for the CPU to wake up from its “slumber”, perform a task, and go back to its doing nothing state. These days, it has become even more important to understand this pattern of the CPU, because most chips built today are aimed at returning to their lowest state as soon as possible.
Gustavo Duarte explains this phenomenon in great detail. According to him, an idle CPU is not actually a CPU that’s doing nothing — it is actually a chip that’s running idle tasks.
While the whole CPU is designed to get done with current operations and return to idle quickly, the system requires some technique to wake a chip up and direct it to work on something else.
One technique is through a system timer.
As Duarte discusses, one way to keep a CPU from consuming too much power is to build in longer tick periods. This way, the CPU spends more time idling before waking up, attending to its tasks, and falling asleep again.
What is an Idle Task?
As mentioned above, a CPU always has to be doing something, even when that “something” is actually nothing. And that certainly does not include its “busy waiting” state.
For 32-bit Windows, this idle state is achieved with the halt (HLT) instruction and the Windows System Idle Process.
- Windows System Idle Process
The idle process is scheduled to run when there are no other threads waiting for execution by the CPU core. That’s why when you run the Task Manager in Windows, you find Windows System Idle Process taking up a high percentage. This means it’s actually showing you how less the CPU is working.
- HLT Instruction
The HLT instruction actually makes the CPU consume as little power as possible, saving huge reserves of energy.
The HLT instruction was implemented in the first 8086 processors, but there was a time when even the basic HLT functionality didn’t always run as intended.
Windows 8 improved this area, with pretty odd results. It allowed for a much longer tick between processes by default, but this led to problems with Google Chrome, which automatically sets the shortest tick rate the operating system allows, in order to improve system response. This problem has now been catered for in the updated versions of the OS.