Here, generic PM is the name given by us. It refers to the conventional power management methods in Linux system, including power off, standby or hibernate, reboot, etc. These methods were used in the era of PC or server before the popularity of embedded Linux. In that wild age of computer science, stimulated by Moore’s law, human beings pursued the computing power and processing performance of computer assiduously, so they didn’t pay special attention to power consumption.

Under this background, the Linux power management mechanism is extensive, static and passive. Please refer to the following introduction for details.

The manifestation of generic PM in Linux operating system

In Linux operating system, operations related to generic PM are as follows:

This image is captured from the “Linux Ubuntu 2.6.32-38” system used by cochlear. It consists of three parts

The first part is the interface of system shutdown and restart, including hibernate, restart and shutdown;

2. The third part is the setting of “power management properties”. The so-called power management properties can be used to configure the system in different power supply modes (such as AC power, battery, etc.). Since the machine is a PC, there is no battery power supply option), how long after it is in the inactive state, the system will turn off the display or enter the sleep state.

This article will focus on the above-mentioned terms, their meaning and implementation in the kernel. Before you start, explain the meaning of these words.

Shutdown, which is easy to understand, means to shut down. At the same time, it means no longer using computers.

Restart, which is easy to understand, means to restart the system. Restart the process, no longer use the computer.

Hibernate, hibernate.

When you hear the word “hibernation”, are you in a daze? In “Linux power management (1)”_ When explaining the concept of power management in “overall architecture”, it was mentioned that hibernation of animals is one of the power management methods designed by nature. In the animal kingdom, hibernation refers to the physiological state that animals (usually for warm blooded animals) enter into by lowering their body temperature. In this state, they need to consume less energy, so as to achieve the purpose of saving electricity (energy).

In the computer industry, designers also borrow the concept of “hibernation”, when it is not necessary to use the computer, save all its current scene (the program executed, the image displayed on the display, the sound being played, etc.) to some memory (such as hard disk) that will not be lost after power failure, and then turn off the computer. After re opening, the system will read out and restore the scene before closing from the memory. At this time, from the user’s point of view, the computer seems to have not been shut down.

If we move the “hibernation” of the computer world to the animal world, it will be like this: a dinosaur, walking in the woods, eating bananas, staggering. Then the boring monkey came and called “Ding!” That’s where the dinosaurs are. Then, ten thousand years later, the boring monkey came again and called “move!” The dinosaurs continued to walk in eight character steps, eating bananas, as if nothing had happened.

Sleep, sleep. The word comes from biology, too. Imagine the difference between “sleep” and “hibernation”? “Sleep” sleep light, can wake up at any time. In the computer, hibernate needs to save the scene to the memory that will not be lost after power failure, and read it back when waking up, which may take a long time (because the access speed of memory that will not be lost after power failure is relatively slow). If you want to hurry up, just save the scene in memory. This is sleep. However, there is a price to pay. If the memory needs to be powered, it will consume energy. You can’t have it both ways!

Auto sleep, to view the third part of the above picture, you can set “how long after the system is in the inactive state, it will automatically enter the sleep state”. For example, I was writing this article, and then my wife called me to kneel on the washboard for two hours. In these two hours, the computer will no longer be used. If it does not enter sleep state, it will consume a lot of energy. In order to avoid unnecessary consumption, the system can automatically sleep when it meets the conditions (such as 20 minutes without use).

The principle of auto put display to sleep is similar, but the object of operation is display.


I wonder if readers have noticed that cochlear has been emphasizing “the computer is no longer used” in red when explaining the above words. This is the essential difference between generic PM and runtime PM, that is, whether the user needs to suspend the use of the computer (even for a short period of time) according to the user’s subjective will.

This is also the reason why generic PM is widely used in the traditional computer operating system, because the use of computers at that time was mostly active. For the current mobile Internet, it is very inappropriate, because people need mobile devices to be online in real time and receive passive events (such as calls) in real time, so it is impossible to stop using them subjectively (even for a short period of time). This difference in the final requirements will lead to great differences in software design. Because of this, the emergence of runtime PM and its maturity as soon as possible are particularly important.

Software architecture of generic PM

After introducing the basic concept of generic PM, let’s take a look at its overall implementation in Linux kernel, and abstract a simple software architecture, so that we can make a more detailed analysis of the main components of generic PM in subsequent articles. The details are as follows:

According to the above description, generic PM mainly deals with shutdown, restart, hibernate and sleep (also called suspend in kernel). In the kernel, there are three software layers

API layer is used to provide interface to user space. The interface form of shutdown and restart is system call (in the new kernel, there is a new way of shutdown interface, which will be discussed later). The interface form of hibernate and suspend is sysfs.

PM core, located in the kernel / power / directory, mainly deals with core logic independent of hardware.

PM driver is divided into two parts. One is architecture independent driver, which provides driver framework. The other part is the specific architecture related driver, which is also involved in the development of power management driver (the module with red border in the figure).

In addition, power management is a system level module, which will involve equipment model, process management and other aspects. We can savor it carefully in the follow-up specific analysis process.

Leave a Reply

Your email address will not be published. Required fields are marked *