What does a CPU do when it’s doing nothing? Your CPU spends - TopicsExpress



          

What does a CPU do when it’s doing nothing? Your CPU spends the vast majority of its time doing absolutely nothing. This is a fact that most tech enthusiasts are generally aware of, but the mechanics of how a CPU does nothing, switches over to briefly do something, and then returns to doing nothing again isn’t something we’ve discussed in great detail. It’s a question that’s increasingly important to modern processors; the goal of most chips built today is to return to their lowest power states as quickly as possible. As detailed by Gustavo Duarte, an idle CPU isn’t actually a CPU that’s doing nothing — it’s a chip that’s running idle tasks. The entire CPU is designed to finish up current operations and return to idle as quickly as possible, but the system has to have some method of waking a chip and telling it to pay attention to something else. One of the ways this happens is via 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 basic tasks, and falling asleep again. What’s an idle task? For a human, an idle task might sound like a contradiction in terms. The key to understanding the CPU equivalent is that a CPU always has to be doing something, even when that something is actually nothing. It’s the philosophical opposite to so-called “busy waiting,” which tells a CPU to continuously evaluate a condition to see if it’s true. For x86 chips running Windows, this function takes the form of the halt (HLT) instruction and the Windows System Idle Process. Windows schedules the idle process to run on a CPU core only when there’s no other threads eligible for execution on that CPU. If you look at the list of running processes on a Windows system, you’ll often see the System Idle Process running at a high percentage. Unlike the other processes on that list, however, this is actually a measure of how little the CPU is working, not how much. The HLT instruction is designed to consume as little power as possible and dropping the CPU into this state saves significant amounts of energy. The history of HLT The HLT instruction is actually quite old — it was implemented in the first 8086 processors, but it wasn’t supported in early operating systems. Some of you old-timers may recall that there was a time when even the basic HLT functionality didn’t always run as intended. Back in the old days of overclocking, there was a basic CPU utility called Rain that actually increased the amount of time a chip spent idle (and improved thermals and power consumption in the process). As time has passed, we’ve seen an increasing degree of sophistication from both hardware manufacturers and software developers. This is one area where Windows 8 innovated — well, attempted to innovate — but with some odd results. It allowed for a much longer tick between processes by default, but it also led to some problems with programs like Google Chrome, which automatically sets the shortest tick rate the operating system allows for, in order to improve system response. This behavior has since been fixed in later versions, but may have been responsible for some Windows 8 computers showing lower battery life. This is also a place where adjustable tick times, combined with a move to support systems without crystal-based timers, caught Microsoft off guard. It’s now possible for software to adjust the front-side bus speed in Windows 8 in ways that futz with the operating system’s timekeeping, leading to erroneous benchmark results. This behavior actually persists in Windows 10, though it remains a niche issue — you have to adjust the system’s FSB clock while inside the operating system to generate erroneous results. While the original blog post is primarily concerned with desktop operating systems, the race-to-idle is the most critical component of a modern CPU’s architecture. AMD and Intel both iterate on a yearly basis, often pushing out updates that may only move the performance bar slightly, but significantly improve power consumption by implementing better clock gating and faster power mode shifts.
Posted on: Mon, 10 Nov 2014 03:38:56 +0000

Trending Topics



Recently Viewed Topics




© 2015