TechWeb

Langa Letter: To Sleep, Perchance To Hibernate...

Sep 29, 2002 (08:09 PM EDT)

Read the Original Article at http://www.informationweek.com/news/showArticle.jhtml?articleID=6503205


I regularly get E-emails like this:

Hi, Fred, You've used the terms "sleep mode," "suspend mode," "standby," and "hibernate." What's the difference? - Jennie K

They're all descriptive terms for varying levels of power management on a PC, but the reason it's confusing is that what one vendor calls "sleep" another may call "standby." Or, even more confusingly, different vendors may both use the same term to mean very different power states.

But things become clearer when you substitute industry-standard terms in place of the descriptive English words. For example, most PCs today support six distinct power modes, or "sleep states," commonly defined as S0 through S5.

You can see the logic of the naming convention if you think of S0 as "sleep state zero," or "sleep zero"; in other words, no sleep at all. In fact, S0 is indeed a system's normal full-power state, or what we'd usually simply call "on." Modes S1-S4 offer increasing levels of power savings, which we'll fully explore in a moment. S5 is the highest power-savings mode, representing a complete power-off such as that achieved by a shut down command.

OK, S0 and S5--on and off--are pretty obvious, but what about the states in between?

S1, S2, and S3 all are low-power, energy-saving states from which the PC can be awakened by jiggling the mouse or tapping a key. (Other external events, such as a special kind of LAN packet or an inbound modem call, also can trigger a wake-up, depending on how the system is set up.) When the PC awakens, it picks up from where it left off when the low-power mode kicked in--the same files will be open, the same apps will be running, etc.

Beyond this broad similarity, the three modes differ:

S1 is the simplest energy-saving state, often used in older systems whose drivers or hardware won't behave well with more sophisticated levels of power management. A system at the S1 power level simply shuts down the hard drive(s) and monitor, but leaves everything else running normally. Different vendors call S1 by different names, but sleep or standby are perhaps the most common.

S2 offers greater power savings because it not only powers down the monitor and drives, it also cuts power to the CPU and its cache. Confusingly, this level also is sometimes called sleep or standby.

S3 is a deeper power-savings mode that shuts down almost everything except for the barest trickle of power needed to keep the contents of RAM from fading away and to listen for a wake-up action. In a way, you can think of S3 as a "suspend to RAM" state. In fact, many vendors do refer to S3 as "suspend" mode, but others (alas) may call it standby, sleep, instant on, on now, and the like.

Note that, although states S1, S2, and S3 all save energy compared with a full-on PC, they still need at least a trickle of electricity to enable the PC to watch for a wake-up event, and to preserve the contents of RAM. That's a key point: If your PC loses power while it's in mode S1, S2, or S3, any information held in RAM--for example, open and unsaved documents or files--will be lost or damaged.

Level S4 is fundamentally different from levels S1 to S3. It's hibernation, where the system stops all activity, just as if you had shut it off. But S4 is also different from the simple power-off of level S5 because, before powering down, the S4 hibernation system writes the contents of RAM and some CPU settings to a special file on your hard drive (often called something like "hiberfil.sys"). Because the PC is truly off--drawing no power--it can't watch for a key press or mouse movement to wake up; you usually have to hit the power switch to bring the system out of hibernation. But when the PC awakens from hibernation, it doesn't have to go through a full reboot. Instead, it reads the contents of the hibernation file back into memory, and thus restores itself to the exact same condition it was in when hibernation started. Although this takes longer than waking from a sleep or standby or suspend mode, it's usually much faster than a full boot. Plus, because the PC is truly off during hibernation, there's nothing live in RAM, so a power failure will have no effect on the system because all the normally volatile information in the system is safely stored in the hibernation file on your hard drive.

Although S0 through S5 are the main power states we need to consider, to be technically complete I should point out that there are actually more power states and variations for different components or situations, depending on (for example) whether a system is powered off mechanically or by software such as in a "warm reboot." All these power states are defined in the industry-standard Advanced Configuration and Power Interface specification, developed by Compaq, Intel, Microsoft, Phoenix, and Toshiba. It's a published spec, and you can read it online at the ACPI consortium's home page. Two of the original collaborators of the ACPI spec--Microsoft and Intel--also have excellent ACPI information online.




Power-Management Problems
The current ACPI general specification (version 2.0) is only about 2 years old, and it's still evolving. The last revision--2.0a--was released in March. It's actually a well-thought-out and well-supported spec whose overall intent is to define a way in which all the hardware and software on a system can communicate and interact with regard to their current power states, needs, and abilities. One familiar example of this interaction is the "intelligent" power switch found on most new PCs: When the PC is on, pressing the nominal "power" switch doesn't simply kill the power; rather, it sends a signal through ACPI to the operating system, which then initiates a controlled shutdown. With ACPI, an operating system may even let you assign different functions--sleep, suspend, hibernate, off--to the power switch.

Most newer systems, add-on devices, and operating systems support the current ACPI spec and thus offer excellent power control. They can, for example, shut down to any of several low-power or power-off modes, then resume operation without difficulty.

But older systems may not handle power-management tasks so gracefully, and here's why: ACPI replaced an older, less-versatile Advanced Power Management spec, which basically just put the BIOS in control of power management. This is fundamentally different from ACPI, so hardware and software designed for APM may not work well with ACPI, and vice versa.

If the computer industry had made a clean break from APM, things might have worked more smoothly, but that's not how it went. For several years in the mid- to late 1990s, APM and ACPI were both in wide play. As a result, it was not at all uncommon for a given system to have an operating system, a system BIOS, and hardware drivers that might be designed either for different power-management standards or different versions of the same standard.

What's more, the old APM spec was never very good to begin with, and the initial versions of ACPI also had rough edges that sometimes prevented systems from living up to their power-management potential.

In short, for several years, power management was a mess. This is one reason power-management problems (including Windows' infamous "hang on shutdown" glitch) are so common in systems more than a couple of years old.

(By the way: The permanent fix for that type of problem usually involves getting current drivers for all add-on hardware and updating your system BIOS. See, for example, How To Troubleshoot Windows 98 Shutdown Problems. Or check out the many third-party sites with information on solving shutdown problems here. Microsoft also has archival information on the now-obsolete APM spec that may be useful if you're struggling with power management on older, APM-era hardware.)

Fortunately, the current ACPI spec makes most of this moot: If your operating system, BIOS, and device drivers all support the current ACPI 2.0 spec, odds are power management will work as it should on your system.

Adjusting The Sleep/Power States
If your system supports the current ACPI spec, you may be able to attain very high levels of energy savings by either or both of two methods: First, see what operating-system-level power-management options are available to you. For example, in Windows, open Control Panel, click on the Power applet, and explore your choices.

Your PC's BIOS may also offer secondary adjustments. For example, some BIOS setup utilities let you assign a default ACPI power setting to be used whenever the operating system calls for a sleep mode. I have a system with an Award BIOS, for instance, that lets me specify either the S1 or S3 sleep modes (see above). By choosing S3, I can ensure greater energy savings. Conversely, if my system experiences trouble going into or recovering from the "deep sleep" of S3, I could use S1 to achieve greater stability, albeit with lesser energy savings. To access your BIOS setup, watch your screen at startup for instructions: Usually, you must press a key--the "Del" key is commonly used--before you hear the system beep. If you can't find a way into your BIOS setup, visit your system vendor's Web site for information.

The exact power-management choices open to you will depend on the specifics of your hardware and software, but here are some links to get you started:

A feature article called Power Management In The Corporate Network (Win2K/XP) offers good, practical implementation advice on ACPI systems.

Microsoft offers Windows users a large amount of operating-system-specific power-management information for WinXP, Win2000, Win98, WinME, and Win95.

Users running Linux on Intel- or AMD-type hardware can obtain tons of ACPI information here.

Once you know the choices available to you, you can make better use of them, saving energy--and money--in the process!

What are your power-management experiences, tips, and tricks? Join the Listening Post discussion at http://www.informationweek.com/forum/fredlanga