在查看中断处理程序(ISR)的运行方式时,我有些困惑。在 Wiki http://en.wikipedia.org/wiki/Context_switch中,它通过 2 个步骤描述了中断处理:
1)上下文切换
When an interrupt occurs, the hardware automatically switches a part of the
context (at least enough to allow the handler to return to the interrupted code).
The handler may save additional context, depending on details of the particular
hardware and software designs.
2)运行处理程序
The kernel does not spawn or schedule a special process to handle interrupts,
but instead the handler executes in the (often partial) context established at
the beginning of interrupt handling. Once interrupt servicing is complete, the
context in effect before the interrupt occurred is restored so that the
interrupted process can resume execution in its proper state.
假设中断处理程序是上半部分,用于内核空间设备驱动程序(我假设用户空间设备驱动程序中断遵循相同的逻辑)。
当中断发生时:
1) 当前内核进程被挂起。但context
这里的情况如何?根据 Wiki 的描述,内核不会产生新的进程来运行 ISR,而且context established at the beginning of interrupt handling
, 听起来很像被中断进程中的另一个函数调用。那么中断处理程序是否使用interrupted process
's stack(context) 来运行?或者内核会分配一些其他内存空间/资源来运行它?
2) 因为这里的 ISR 不是可以被调度程序置于睡眠状态的“进程”类型。无论如何都必须完成?甚至不受任何时间片的限制?如果 ISR 挂了怎么办,系统如何处理?
对不起,如果这个问题是基本的。我对这个主题的研究时间还不够长。
谢谢,