吼吼,文章名字很唬人啊。這裡只是記錄我在研究Linux Kernel原始碼時碰到的有意思的,而目前不知道為什麼的問題。
* * * * *
1)為什麼Interrupt handler不能睡眠,或者更嚴格的說,被調度(rescheduled)
目前引用最廣泛,也最容易理解的解釋是, 1)Interrupt context is time-critical because the interrupt handler interrupts the other code. Code should be quick and simple。2)Interrupt context is not associated with a process. The current macro is not relevant
(although it points to the interrupted process). Without a backing process, interrupt context cannot sleep --- how would it ever reschedule?
以我個人觀點,這兩條解釋最多算作建議,即他建議你不要在Interrupt handler中睡眠,但你偏要睡眠他也沒辦法。既然kernel的scheduler會儲存CPU的所有狀態,從技術實現的可行性上說,應該可以對Interrupt handler進行調度,事實上只要調度被此Interrupt handler中斷的process就行,即上面第二條解釋的中說的current指向的與此Interrupt handler不相關的process。當然這樣做會影響系統的相應速度,但這裡只強調技術實現的可行性。
這個想法應該很好驗證。
* * * *
2)為什麼read/write memory barrier不能保證transitivity,而general barrier可以保證
Documentation/memory_barriers.txt中給出的結論,不知道為什麼。以我個人觀點,從語義上來說read/write memory barrier應該可以保證傳遞性。