Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does a CPU idle (or run below 100%)?

I first learned about how computers work in terms of a primitive single stored program machine.

Now I'm learning about multitasking operating systems, scheduling, context switching, etc. I think I have a fairly good grasp of it all, except for one thing. I have always thought of a CPU as something which is just charging forward non-stop. It always knows where to go next (program counter), and it goes to that instruction, etc, ad infinitum.

Clearly this is not the case since my desktop computer CPU is not always running at 100%. So how does the CPU shut itself off or throttle itself down, and what role does the OS play in this? I'm guessing there's an input on the CPU somewhere which allows it to power down... and the OS can set this if it has nothing to schedule, but the next logical question is how does it start back up again? I'm guessing either one of two things:

  • It never shuts down completely, just runs at a very low frequency waiting for the scheduler to get busy again
  • It shuts down completely but is woken up by interrupts

I searched all over for info on this and came up fairly empty-handed. Any insight would be much appreciated.

like image 370
Dave Johnson Avatar asked Aug 02 '13 03:08

Dave Johnson


People also ask

What does a CPU do when idle?

A computer processor is described as idle when it is not being used by any program. Every program or task that runs on a computer system occupies a certain amount of processing time on the CPU. If the CPU has completed all tasks it is idle. Modern processors use idle time to save power.

What is a good CPU idle temp?

A good temperature for your desktop computer's CPU is around 120℉ when idle, and under 175℉ when under stress. If you're using a laptop, you should look for CPU temperatures between 140℉ and 190℉.

How is CPU idle time calculated?

If you mean clock cycles spent in idle, just multiply the idle percentage by the number of CPU cycles per second and the number of seconds (assuming a single CPU).

Why is a CPU often idle?

CPU is often idle, because the speed of the mechanical I/O devices is slower than the CPU.


2 Answers

The answer is that is depends on the hardware, the operating system and the way that the operating system has been configured.

And it could involve either or both of the strategies you proposed.

Another possibility for machines based on the x86 architecture, is that x86 has an HLT instruction that causes the core to stop until it receives an external interrupt. So the "Idle" task could simply execute HLT in a tight loop.

like image 112
Stephen C Avatar answered Sep 16 '22 21:09

Stephen C


Just go to task manager, performance tab, and watch the cpu usage while you're doing absolutely nothing on your computer. it never stops fluctuating. Having an operating system like windows running, the cpu is going to ALWAYS be functioning, it never completely shuts down.

Having your monitor display an image requires your cpu to process a function allowing it to display anything. etc.

Everything runs through the CPU, just like your brain, it controls everything. nothing would function without it.

like image 32
Outdated Computer Tech Avatar answered Sep 17 '22 21:09

Outdated Computer Tech