⬆️ ⬇️

What does the CPU do when it is not doing anything?

It's funny, but microprocessors inside the devices on which you read "Hiktimes", most of the time, almost do nothing. This fact is well known to people who have somehow connected their lives with the field of information technology. The man in the street has a poorly known mechanic for moving the processor to the idle state and leaving it.



The ultimate goal of modern processors is to get rid of their tasks and quickly switch to the mode with minimal power consumption. In fact, the idle processor is not idle, but is busy with idle processes, because it will need to be “woken up” when a task occurs.



It sounds mutually exclusive to a person, but to understand these terms it’s worth remembering that the CPU is always doing something, even at that moment when he really doesn’t do anything.

')

On Windows, this process looks like the System Idle Process or System Idle. The idle process has one or more threads, and the main purpose of its existence is to eliminate the need for special conditions in the task scheduler. If it were not there, then a situation could arise where there is not a single stream available to start, but due to the constant availability of one or several idle task threads, this does not happen.







In the presented example of the idle cycle by using the system timer, the timer interrupt is programmed by the kernel for every four milliseconds, and this is called the tick period. Here we have a tick of 4 milliseconds or 250 ticks per second - a popular value in Linux operating systems (of course, it can be changed when compiling the kernel by changing CONFIG_HZ). Another known value is 100 ticks per second. A high time period between tics, that is, a decrease in their frequency, promises higher energy efficiency.



The x86 architecture uses the HLT stop command. Its age is already quite large, it was introduced in the first 8086 processors, it was also in 8080. That was the time when the number of transistors in chips was measured in tens of thousands. But in the early operating systems there was no support for this command, and PC users of that era can remember the utilities Rain, Waterfall, and CPUIdle, which increased the amount of time the microprocessor spent in idle time, which reduced power consumption and heat generation.







In the Windows NT family of operating systems, the idle process is used to save energy. The specific scheme of the mode of reduced consumption differs in different operating systems and processors. For example, an x86 processor running Windows 2000 will cycle through the HLT instruction until it receives a completion signal. This leads to the shutdown of many internal components of the microprocessor. In later versions of Windows, this scheme looks more complicated, using a layer of hardware abstractions to reduce the processor clock frequency or introduce other power saving mechanisms.



The inactivity process is always the lowest priority, and the OS scheduler will never select it for execution if there is another thread ready to start. There are other peculiarities in idle processing of its execution priorities, for example, the HLT command can only be run by the kernel.



If you open the Task Manager, you can often see how much the inactivity process “loads” the computer, but unlike other processes, its indicator illustrates how much resources or processor time are available during the current computer operation. (Of course, it may be more convenient to monitor idleness in the Performance Monitor, which runs on its own name perfmon.) In some operating systems, the idle process is built into the scheduler.



AMD and Intel improve the performance of their products year after year. Although most often we pay attention only to improving performance, the battle for power consumption also takes place: from a model to a model, techniques of gaming are improved, dynamic control of the frequency of the computing cores depending on the load, power outage of unused units and adjustment of the voltage level of the system components.



Based on Extreme Tech , Gustav Duarte's personal blog and Wikipedia.org ( 1 , 2 , 3 ).

Source: https://habr.com/ru/post/362711/



All Articles