more: Jollen 的 Embedded Linux 教育訓練

« Linux 驅動程式的中斷處理, #2: 深入淺出中斷模式 | Home | Openmoko 開放 Neo 手機工業設計 »

Linux 驅動程式的中斷處理, #3: Bottom Half 的觀念

jollen 發表於 March 3, 2008 11:36 PM

為了能寫出很棒的 interrupt handle,Linux 採用一種稱為 bottom half 的觀念來實作 interrupt handler。

bottom_half.PNG

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

引用通告

如果您想引用這篇文章到您的Blog,
請複製下面的鏈接,並放置到您發表文章的相應界面中。

http://blog.jollen.org/mt-tb.cgi/483

評論 (3)

匿名:

您好..在最後一段提到 bottom half 就是 interrupt handler
而在之前又提到
Top half 是在呼叫 request_irq() 時所指定的 interrupt handler 函數
請問一下..兩者之間的差異..
謝謝..

jollen:

Hi,

bottom half 是 interrupt handler 的一部份,top half 是立即回應中斷事件的 task。bottom half 是排程執行的 interrupt handler,由 top half 以 tasklet 做排程。

Qutie:

你說bottom half 就是 interrupt handler,因此「也視為」在 interrupt mode 下執行。 "也視為在 interrupt mode下執行" 這句話你想要表達的是什麼? 謝謝 ^___^

發表一個評論

(您發表的意見將被立即接受,但需要一點時間與後端伺服器做同步,您的留言才會顯示在網站上。為避免 spam 攻撃,按「發表」後請輸入帳號密碼。使用者帳號:「nospam」、密碼:「nospam」。)

Top | 授權條款 | Jollen's Forum: Blog 評論、討論與搜尋
Copyright(c) 2006 www.jollen.org