Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens in the CPU when there is no user code to run?

It sounds reasonable that the os/rtos would schedule an "Idle task". In that case, wouldn't it be power consuming? (it sounds reasonable that the idle task will execute: while (true) {} )

like image 628
Yony Avatar asked Nov 28 '22 08:11

Yony


1 Answers

This depends on the OS and the CPU architecture. On x86 (Intel compatible) the operating system might execute HLT instructions, making the CPU wait until something interesting happens, such as a hardware interrupt. This supposedly consumes very little power. Operating systems report the time spent doing this as "idle" and may even assign it to a fictional "idle" process.

So, when in Windows task manager you see that the System Idle Process is consuming 90% CPU what it really means is that the CPU does not have an actual a program to run 90% of the time.

Here's a good article on the subject: What does an idle CPU do?

like image 80
Joni Avatar answered Dec 28 '22 10:12

Joni