Recently, I have just made a research report on the implementation of suspend to disk in the android system of power management. Recently, I just sorted it out in a relatively idle manner.
I am based on the jz4780grus development board of beijing junzheng. I will make a study report based on the following in the past few days. The content of this report is as follows:
1. Introduction to Linux sleep/Wakeup
1. describes four statuses of Suspend in Linux.
2. Linux sleep steps
3. user space Interface
4. Linux Suspend Process
5. Linux Resume process
II. Introduction to Android sleep (suspend)
1. Introduction to sleep in android
2. Features of android sleep
3. Android suspend execution process
4. Android wake Lock Execution Process
5. Differences between Android and standard Linux sleep
Iii. Execution flowchart of suspend to RAM in android
IV. Implementation flowchart of hiernation in android
5. Comparison of my implemented solutions and implementation methods
Vi. Test Data and Solutions
I will start to introduce it as follows:
Power Management
Preface:
Standby
The computer stores the current running status and other data in the memory, closes the hard disk, peripherals, and other devices, and enters the waiting state. At this time, the memory still needs power to maintain its data, but the power consumption of the entire machine is very small. During restoration, the computer reads data from the memory and returns to the State before suspension, which is faster. Generally, a laptop can be suspended for several hours or even several days when the battery is fault-free and full (depending on the specific model ).
Other names: Suspend, STR (Suspend To RAM), suspended, suspended To memory
Sleep
The computer stores the current running status and other data in a file or a specific area on the hard disk, closes the hard disk, peripherals, and other devices, and enters the shutdown status. In this case, the computer is completely shut down without consuming power. During restoration, the computer reads data from the Sleep file/partition and returns to the State before hibernation. The restoration speed is slow. However, because this method completely consumes power and saves the working status, it is often used by notebook users as an alternative to shutdown.
Other names: Hibernation, STD (Suspend To Disk), suspended To hard Disk, sleep To Hard Disk
Sleep/Wakeup is a very important part in embedded Linux. Its functions can be divided into the following two points:
1. Extend the battery life by entering the sleep state;
2. Fast start through sleep;
Next we will introduce in detail how sleep/Wakeup works in Linux, and how to associate this part with the Linux mechanism in Android.
1. Introduction to Linux sleep/Wakeup
1. Four statuses of Suspend in Linux
Suspend/Resume is an important function of Linux system power management. Suspend can enter the low-power active sleep state when the system is not used, thus saving system power. The Suspend of Linux has four States. For different architectures or power management interfaces, the State meanings are not necessarily the same, but there is no big difference. The following describes the meaning of the ACPI Power interface and its corresponding Sleep State.
-On (on) S0-Working
-Standby (standby) S1-CPU and RAM are powered but not executed
-Suspend to RAM (mem) S3-RAMis powered and the running content is saved to RAM
-Suspend to Disk, Hibernation (disk) S4-All contect is saved to Diskand power down
2. Linux sleep steps
In Linux, sleep mainly involves three steps:
1) Freeze user-State processes and kernel-state tasks
2) Call the suspend callback function of the registered device in the order of registration
3) sleep the core device and sleep the CPU into a sleep frozen process. The kernel sets the state of all processes in the process list to stop and saves the environment of all processes. When these processes are restored, they do not know that they have been frozen, but simply continue to execute.
3. user space Interface
How can we break Linux into sleep?
First, we usually use # cat/sys/power/state to obtain the kernel-supported sleep modes.
Next, let's take a look at the suspend user space interface, which is a/sys file system interface and the interface file is/sys/power/state. This is the only interface for operating Suspend in the user space. When we write a valid suspend State to this file, the system will call the Suspend function to enter a valid suspend state. For example, writing a disk to this file will bring the system into the Suspend to RAM status. the following command:
Echo disk>/sys/power/state // sleep the system
In a more general sense, the user calls main to read/write/sys/power/state. state_store () in c. You can write strings defined in const char * const pm_state [], such as "mem", "standby", and ''disk ''. Standby consumes more power and returns less time to normal working status.
Then state_store () will call enter_state (). It will first check some status parameters and then synchronize the file system.
Not yet resumed !!
My opinion. If you have any questions, please correct them !!
Reprinted please indicate the source: http://blog.csdn.net/wang_zheng_kai