我讀了一些相關的帖子:當中斷處理程序被另一箇中斷中斷時,中斷上下文如何「恢復」?
(1)從羅伯特·愛:http://permalink.gmane.org/gmane.linux.kernel.kernelnewbies/1791
You cannot sleep in an interrupt handler because interrupts do not have a backing
process context, and thus there is nothing to reschedule back into. In other
words, interrupt handlers are not associated with a task, so there is nothing to
"put to sleep" and (more importantly) "nothing to wake up". They must run
atomically.
(2)從Which context are softirq and tasklet in?
If sleep is allowed, then the linux cannot schedule them and finally cause a
kernel panic with a dequeue_task error. The interrupt context does not even
have a data structure describing the register info, so they can never be scheduled
by linux. If it is designed to have that structure and can be scheduled, the
performance for interrupt handling process will be effected.
所以,在我的理解,中斷處理程序在中斷上下文中運行,並且無法進入睡眠狀態,也就是說,不能像正常進程那樣執行上下文切換。
但是中斷處理程序可以被另一箇中斷中斷。當第二個中斷處理程序完成其工作時,控制流將跳回第一個中斷處理程序。
如何在沒有正常的上下文切換的情況下實現「恢復」?它是否像正常的函數調用一樣,將所有寄存器和其他相關內容存儲在某個堆棧中?
Robert Love:* ...因爲中斷沒有支持 進程context_ *和Softirq/tasklet:*中斷上下文甚至沒有描述註冊信息的**數據結構**。在這兩種情況下,技術描述都是沒有'thread_info','task_struct'或'struct mm'。你需要調度一個'task_struct'。中斷等可以在'thread_info'中作爲堆棧內核上下文的*堆棧*。 –