https://blog.csdn.net/coldsnow33/article/details/18138995 reprint!
https://blog.csdn.net/qq_28779021/article/details/80046713 reprint!
https://www.linaro.org/blog/suspend-to-idle/
https://www.cnblogs.com/deng-tao/p/6026373.html
This article is himself the basis of previous practice a bit on the way to write about experimental records.
View system supports sleep mode:
cat /sys/power/state
1 suspend state
suspend to idle, power-on standby (Standby), suspend to ram (STR) and sudpend to disk (Hibernate), the corresponding ACPI state S0, S1, S3 and S4. suspend four states Linux system, for different architectures or Power Management Interface, the state is not necessarily exactly the same meaning, but there is not much difference. The following is the meaning of ACPI and power interface corresponding to Sleep State.
State in Linux | Label | state | ACPI state | Note |
#define PM_SUSPEND_ON ((__force suspend_state_t) 0) | everything is normal | |||
#define PM_SUSPEND_FREEZE ((__force suspend_state_t) 1) | freeze | Suspend-to-Idle | S0 | Freezing process + + CPU idle pending device |
#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 2) | standby | Standby/Power-on Suspend | S1 | Freezing process equipment + + hang close nonbootCPU |
#define PM_SUSPEND_MEM ((__force suspend_state_t) 3) | mem | Suspend-to-RAM | S3 | RAM self-refresh only reserved |
#define PM_SUSPEND_MAX ((__force suspend_state_t) 4) | disk | Suspend-to-disk | S4 | Close all devices, including RAM, also referred to as Hibernate |
From the freeze -> standby -> mem deeper level of sleep, wake up spending more and more time.
By writing to / sys / power / state different strings, you can put the system into different sleep states. Such as the following:
echo mem> / sys / power / state let the system go to sleep.
echo on> / sys / power / state to make the system wake-up.
2 suspend user space Interface
Power management system Linux driver model Suspend frame with Linux system (Linux Driver Model) is relevant, but also Linux-based driver model implemented . Suspend the Linux system is divided into two parts, one is a platform-independent core layer, the platform layer and the other is platform-dependent. Operation interfaces in platform-independent core layer inside.
The Linux driver model system , device structure describes a device, the device_driver drive apparatus, and class, type and describe the bus type, and the type of bus device belongs. And the power management device according to the model is also divided into class level, type level, bus driver stage and grade. If the class of a device or bus knows exactly how to manage the power of a device when the drive level suspend / resume that can be empty. This greatly improves the efficiency and flexibility of power management.