事件等待队列一般用于linux驱动的异步通信,也可以叫做申请设备使用权等待队列。当多个进程去操作一个设备时,这个时候一般要用到事件队列。 1、不可中断睡眠:0 g) z% W6 w, [5 @- C% Z" z
wait_event(queue, condition)
9 p+ w3 e$ X. P+ T8 O wait_event_interruptible(queue, condition)- z8 o% T) v& e. @/ [2 w' P
两个函数只有在condition变为true才能唤醒,否则一直睡眠,即是调用wake_up()也不能唤醒。
. k5 @" l+ J7 r7 f 2、可中断睡眠
. R* b. J% o# P wait_event_timeout(queue, condition, timeout)
# l6 `$ ], B5 h( e2 z e0 l wait_event_interruptible_timeout(queue, condition, timeout)
8 R- _: i/ f! [9 `* g( v- k+ j/ P 两个函数在condition变为true或wake_up_interruptible()被调用都能被唤醒。: v* R- J! D* C; T& x
3,唤醒函数:( z% B1 e" `. X3 ?
void wake_up(wait_queue_head_t *queue); //唤醒所有. s1 K, i4 k: g/ q! g4 Z. s, I; L
void wake_up_interruptible(wait_queue_head_t *queue); //唤醒interruptible |