1.定義等待佇列
wait_queue_head_t my_queue;
2.初始化等待佇列
init_waitqueue_head (&my_queue);
3.定義並同時初始化佇列
declare_wait_queue_head (my_queue);
4.利用等待佇列使程序睡眠
wait_event(queue,condition); // condition為真時立即返回,condition為假時睡眠
wait_event_interruptible(queue,condition); // condition為真時返回,condition為假時睡眠
wait_event_killable(queue,condition); // condition為真時返回,condition為假時睡眠
sleep_on(wait_queue_head_t queue); // 進入不可中斷睡眠狀態(2.4核心)
interruptible_sleep_on(wait_queue_head_t queue); // 進入可中斷睡眠狀態
5.從等待佇列中喚醒程序
wake_up(wait_queue_head_t queue); // 喚醒等待佇列中的所有程序
wake_up_interruptible(wait_queue_head_t queue); // 喚醒可中斷程序
核心等待佇列 筆記
可以用等待佇列來實現程序的阻塞 操作方法 1 定義等待佇列 wait queue head t my queue 2 初始化等待佇列 int waitqueue head my queue 3 定義並初始化等待佇列 declare wait queue head my queue 4 有條件睡眠 1...
Linux核心等待佇列
在linux驅動程式設計中,可以使用等待佇列來實現程序的阻塞,等待佇列可看作儲存程序的容器,在阻塞程序時,將程序放入等待佇列,當喚醒程序時,從等待等列中取出程序。linux 2.6核心提供了如下關於等待佇列的操作 1 定義等待佇列 wait queue head t my queue 2 初始化等待...
核心等待佇列的介紹
目錄 一 背景和意義 二.資料結構分析 三.等待佇列的操作 3.1 典型應用 3.2 將等待佇列項插入等待佇列 3.3 將等待佇列從等待佇列中刪除 3.4 將等待佇列從等待佇列中刪除 在實際程式設計中,我們會經常碰到這種場景 程序p需要等待條件c的成立,才能繼續執行某個動作。例如,當串列埠沒有資料可...