為了能寫出很棒的 interrupt handle,Linux 採用一種稱為 bottom half 的觀念來實作 interrupt handler。
Linux 將完整的 interrupt handler 切成2個部份(half):top half 與 bottom half。Top half 是在呼叫 request_irq() 時所指定的 interrupt handler 函數,bottom half 則是由 top half 所排程(scheduling),真正負責回應中斷的 task。
一般來說,top half 的基本實作原則如下:
1. 儲存裝置相關資料,這個部份會涉及「中斷不同步」的議題,在這裡先不做解釋。
2. 將 bottom half 排程後結束執行。
Top half 是真正接受中斷請求的 task,因此應避免執行過久。由 top half 的實作原則可以看出,top half 真正要做的工作其實只有排程 bottom half,因此執行的速度將會非常快。Top half 與 bottom half 的最大差別為,bottom half 在執行時,interrupt 是開啟的,因此 CPU 仍然可以接受中斷請求。
由此也可以看出另外一個 bottom half 機制的特點:當 bottom half 尚未結束執行時,top half 仍然可以處理中斷請求。另外,bottom half 就是 interrupt handler,因此「也視為」在 interrupt mode 下執行。
--jollen

評論 (3)
您好..在最後一段提到 bottom half 就是 interrupt handler
而在之前又提到
Top half 是在呼叫 request_irq() 時所指定的 interrupt handler 函數
請問一下..兩者之間的差異..
謝謝..
由 匿名 | March 4, 2008 9:37 AM
發表於 March 4, 2008 09:37
Hi,
bottom half 是 interrupt handler 的一部份,top half 是立即回應中斷事件的 task。bottom half 是排程執行的 interrupt handler,由 top half 以 tasklet 做排程。
由 jollen | March 4, 2008 6:29 PM
發表於 March 4, 2008 18:29
你說bottom half 就是 interrupt handler,因此「也視為」在 interrupt mode 下執行。 "也視為在 interrupt mode下執行" 這句話你想要表達的是什麼? 謝謝 ^___^
由 Qutie | April 24, 2008 2:34 PM
發表於 April 24, 2008 14:34