下载后可任意编辑android 休眠与唤醒驱动流程分析标准 linux 休眠过程:power management notifiers are executed with PM_SUSPEND_PREPARE tasks are frozentarget system sleep state is announced to the platform-handling codedevices are suspended platform-specific global suspend preparation methods are executed non-boot CPUs are taken off-lineinterrupts are disabled on the remaining (main) CPU late suspend of devices is carried out (一般有一些 BUS driver 的动作进行)platform-specific global methods are invoked to put the system to sleep 标准 linux 唤醒过程:the main CPU is switched to the appropriate mode, if necessaryearly resume of devices is carried out (一般有一些 BUS driver 的动作进行)interrupts are enabled on the main CPU non-boot CPUs are enabled platform-specific global resume preparation methods are invokeddevices are woken uptasks are thawed power management notifiers are executed with PM_POST_SUSPEND 用户可以通过 sys 文件系统控制系统进入休眠:查看系统支持的休眠方式:#cat /sys/power/state 常见有 standby(suspend to RAM)、mem(suspend to RAM)和 disk(suspend to disk),只是standby 耗电更多,返回到正常工作状态的时间更短。通过 #echo mem > /sys/power/state 让系统进入休眠。Android 休眠与唤醒android 是在传统的 linux 内核电源管理设计的基础上,结合手机设计的实际需求而进化出的一套电源管理系统,其核心内容有:wakelock 、early_suspend 与 late_resume。wakelock 在 Android 的电源管理系统中扮演一个核心的角色。wakelock 是一种锁的机制, 只要有人拿着这个锁,系统就无法进入休眠,可以被用户态程序和内核获得。这个锁可以是有超时的或者是没有超时的,超时的锁会在时间过去以后自动解锁。假如没有锁了或者超时了,内核就会启动休眠的那套机制来进入休眠。当系统在启动完毕后,会自己去加一把名为“main“的锁,而当系统有意愿去睡眠时则会先去释放这把“main”锁,在 android 中,在 early_suspend 的最后一步会去释放“main”锁(wake_unlo...