Can an interrupt handler be preempted?

二次信任 提交于 2019-11-29 15:17:20

问题


I know that linux does nested interrupts where one interrupt can "preempt" another interrupt, but what about with other tasks.

I am just trying to understand how linux handles interrupts. Can they be preempted by some other user task/kernel task.


回答1:


Simple answer: An interrupt can only be interrupted by interrupts of higher priority.

Therefore an interrupt can be interrupted by the kernel or a user task if the interrupt's priority is lower than the kernel scheduler interrupt priority or user task interrupt priority.

Note that by "user task" I mean user-defined interrupt.




回答2:


Reading Why kernel code/thread executing in interrupt context cannot sleep? which links to Robert Loves article, I read this :

some interrupt handlers (known in Linux as fast interrupt handlers) run with all interrupts on the local processor disabled. This is done to ensure that the interrupt handler runs without interruption, as quickly as possible. More so, all interrupt handlers run with their current interrupt line disabled on all processors. This ensures that two interrupt handlers for the same interrupt line do not run concurrently. It also prevents device driver writers from having to handle recursive interrupts, which complicate programming.

So AFIK all IRQ's are disabled while within the interrupt handler, therefore it cannot be interrupted!?



来源:https://stackoverflow.com/questions/5934402/can-an-interrupt-handler-be-preempted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!