Android电源管理之wake_lock驱动

1.wake_lock是什么?

wake_lock是一个数据结构,是一种锁机制,顾名思义它是一把唤醒锁,只要有用户持有这把锁,系统将无法进入睡眠状态,这个锁可以是有超时的或者是没有超时的,超时的锁会在时间过去以后自动解锁.如果没有锁了或者超时了,内核就会启动标准linux的那套休眠机制机制来进入休眠.wake_lock数据结构在include/linux/wakelock.h中被定义:

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
};


你可能感兴趣的:(Android电源管理之wake_lock驱动)