1. 首先这篇博客讲解得挺好的,推荐
wait_event_interruptible 使用方法
2 .函数原型:
#define wait_event_interruptible(wq, condition)
({
int __ret = 0;
if (!(condition))
__wait_event_interruptible(wq, condition, __ret);
__ret;
})
@wq:等待队列,创建等待队列查看
010_Linux驱动之_DECLARE_WAIT_QUEUE_HEAD函数
@condition:当是0时候进程进入休眠,是1的时候继续往下运行
3. 使用示例:
![](https://img2018.cnblogs.com/blog/1496483/201906/1496483-20190613084011695-822753712.png)
解析上面程序:
1. 在010中创建了一个叫button_waitq的等待队列
2. ev_press是变量,当是0时候进程进入休眠,是1的时候继续往下运行
4. 唤醒使用wake_up_interruptible()函数
当使用上面的程序进入休眠之后,使用wake_up_interruptible函数进行唤醒
使用示例:唤醒上面的程序
![](https://img2018.cnblogs.com/blog/1496483/201906/1496483-20190613084018311-268570212.png)
![](https://img2018.cnblogs.com/common/1496483/201912/1496483-20191226083332289-1534558991.png)