012_Linux驱动之_wait_event_interruptible

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. 使用示例:

解析上面程序:
1. 在010中创建了一个叫button_waitq的等待队列
2. ev_press是变量,当是0时候进程进入休眠,是1的时候继续往下运行
 
4. 唤醒使用wake_up_interruptible()函数
当使用上面的程序进入休眠之后,使用wake_up_interruptible函数进行唤醒
使用示例:唤醒上面的程序
 

原文地址:https://www.cnblogs.com/luxiaoguogege/p/9690237.html