国嵌内核驱动进阶班-7-2(内核等待队列)

定义和初期化

定义等待队列

wait_queue_head_t myqueue;

初始化等待队列

init_waitqueue_head(&myqueue)

定义并初始化等待队列

DECLARE_WAIT_QUEUE_HEAD(myqueue)


 

睡眠

  • 条件睡眠

当condition为真时,立即执行;

wait_event(queue, condition)

当condition为假时,进入TASK_UNINTERRUPTIBLE;

wait_event_interruptible(queue, condition)

当condition为假时,进入TASK_INTERRUPTIBLE;

wait_event_killable(queue, condition)

 当condition为假时,进入TASK_KILLABLE

  • 无条件睡眠

    sleep_on(queue)

    interruptible_sleep_on(queue)


 

唤醒

wait_up(queue)

唤醒所有进程(TASK_UNINTERRUPTIBLE,TASK_INTERRUPTIBLE,TASK_KILLABLE)

wait_up_interruptible(queue)

 唤醒TASK_INTERRUPTIBLE的进程

 

posted @ 2015-06-03 23:14  renhl  阅读(148)  评论(0编辑  收藏  举报