Power Management States

With the exception of the dead state, the computer never completely stops using power. In the suspend state, it uses minimal power to maintain its clock, its applications, and the persistent data stored in RAM. To reduce power requirements, the computer removes power from unneeded circuits and devices, such as the keyboard decoder, display, scratch-pad memory, and processor. A PC Card's driver determines the power that it uses when the computer is in the suspend state.

The computer switches to the suspend state for the following events:

The operating system uses an activity timer to gauge whether the user is actively using the computer. The timer counts down while the computer is in the on state. When the timer reaches zero, the computer switches to the suspend state. The user can set the maximum value of this timer in seconds. Two events reset the timer to its maximum value: a key press or release and a touch event. When the timer reaches five seconds, the computer sounds a warning to alert the user that it is about to suspend operation. The operating system does not notify an application when it enters the suspend state because most applications are not affected by this transition. When the device resumes operation, applications also resume operation as if they had been continuously running.

Functions that applications can use to reset activity times or to set timers and events that can switch the computer from the suspend state to the on state are described in the following table.

Function Description
CeRunAppAtTime Sets a timer or runs an application at a specified time.
WaitCommEvent Waits for a communications event to occur. Serial, Infrared Data Association (IrDA), or PC Card devices can return EV_POWER when the device resumes operation.

If an application uses the Sleep function, it does not increment the elapsed time counter while the computer is in suspend state. It starts counting again when computer operation resumes. The internal clock is not affected when computer operation is suspended. Though an application is not notified when it enters the suspend state, the operating system does notify a device driver by calling a power-handler function. A device driver might use this notification to suspend operation of the device it controls, which may result in a device not being available immediately after the computer switches to the on state. For example, when a file stored on a PC Card is open and the user tries to save the file before the card is turned on, the system returns an error message.

The computer switches to the on state for the following events:

In the on state, the default mode is full-speed. The computer switches from full-speed mode to idle mode when all processes are idle. Switching to idle mode is transparent to the user and most applications, because the system continues to process interrupts, including the time slice interrupt.

When the computer is in the on state, some applications may prevent the operating system from switching the computer to the idle mode. These applications retain control by using idle loops or by using functions that do not let the operating system block operation. All applications can enhance power management by using functions that let the operating system block a return to the application. For example, use the GetMessage function rather than the PeekMessage function, because GetMessage lets the system block a return to the application and PeekMessage does not. Letting the operating system retain control allows it to determine when the system is inactive so that it can select the most efficient operating state for the computer.