1.wake_lock是什么?java
wake_lock是一个数据结构,是一种锁机制,顾名思义它是一把唤醒锁,只要有用户持有这把锁,系统将没法进入睡眠状态,这个锁能够是有超时的或者是没有超时的,超时的锁会在时间过去之后自动解锁.若是没有锁了或者超时了,内核就会启动标准linux的那套休眠机制机制来进入休眠.wake_lock数据结构在include/linux/wakelock.h中被定义:linux
struct wake_lock { #ifdef CONFIG_HAS_WAKELOCK struct list_head link; /*指向全局链表(list_lock)*/ int flags; const char *name; unsigned long expires; #ifdef CONFIG_WAKELOCK_STAT struct { int count; int expire_count; int wakeup_count; ktime_t total_time; ktime_t prevent_suspend_time; ktime_t max_time; ktime_t last_time; } stat; #endif #endif };