010_Linux驱动之_DECLARE_WAIT_QUEUE_HEAD函数
1. 功能:创建以个等待队列头
2. 函数原型
#define DECLARE_WAIT_QUEUE_HEAD (name) /
wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
#define __WAIT_QUEUE_HEAD_INITIALIZER (name) { /
.lock = __SPIN_LOCK_UNLOCKED(name.lock), /
.task_list = { &(name).task_list, &(name).task_list } }
typedef struct __wait_queue_head wait_queue_head_t ;
struct __wait_queue_head {
spinlock_t lock;
struct list_head task_list;
};
3. 使用示例:
![](https://img2018.cnblogs.com/blog/1496483/201906/1496483-20190613083845310-1874456259.png)
解析上面程序:
1. 创建一个名字叫button_waitq的等待队列头
2. 名字任意
![](https://img2018.cnblogs.com/common/1496483/201912/1496483-20191226083032687-461503098.png)