核心驅動之poll機制

2021-06-29 12:38:14 字數 769 閱讀 4504

kernel:sys_poll

do_sys_poll(.....,timeout_jiffies)

poll_initwait(&table);

init_poll_funcptr(&pwd->pt,_pollwait);  > table -> qproc = _pollwait

do_poll(nfds, head, &table, timeout)

for (; ; )

if (count || !*timeout || signal_pending(cuttent))  //有訊號等待處理

break;

_timeout = schedule_timeout(_timeout)     //如果沒有事情發生,則*timeout減為0

}程式分析:

中斷執行:
ev_press = 1;                  /* 表示中斷發生了 */

wake_up_interruptible(&button_waitq); /* 喚醒休眠的程序 */

static unsigned forth_drv_poll(struct file *file, poll_table *wait)

應用程式程式:

while (1)

else

}

感謝韋老師的講解

Linux驅動之poll機制

驅動程式 include 模組有關的 include 核心有關的 include 檔案系統有關的 include include include include include include linux中斷 include include include include copy to user ...

linux驅動編寫之poll機制

1.poll情景描述 以按鍵驅動為例進行說明,用阻塞的方式開啟按鍵驅動檔案 dev buttons,應用程式使用read 函式來讀取按鍵的鍵值。這樣做的效果是 如果有按鍵按下 了,呼叫該read 函式的程序,就成功讀取到資料,應用程式得到繼續執行 倘 若沒有按鍵按下,則要一直處於休眠狀態,等待這有按...

linux驅動編寫之poll機制

一 概念 1 poll情景描述 以按鍵驅動為例進行說明,用阻塞的方式開啟按鍵驅動檔案 dev buttons,應用程式使用read 函式來讀取按鍵的鍵值。這樣做的效果是 如果有按鍵按下了,呼叫該read 函式的程序,就成功讀取到資料,應用程式得到繼續執行 倘若沒有按鍵按下,則要一直處於休眠狀態,等待...