我在查看中断处理程序(ISR)运行方式时有些困惑。维基百科http://en.wikipedia.org/wiki/Context_switch中描述了中断处理的两个步骤:
1) 切换上下文
假设中断处理程序是上半部分,用于内核空间设备驱动程序(我假设用户空间设备驱动程序中断遵循相同的逻辑)。
当中断发生时:
1) 当前内核进程被挂起。但这里的“上下文”情况是什么?根据维基百科的描述,内核不会生成一个新的进程来运行ISR,并且“在中断处理开始时建立的上下文”,听起来非常像中断进程内的另一个函数调用。那么中断处理程序是否使用“中断进程”的堆栈(上下文)运行?还是内核会分配一些其他的内存空间/资源来运行它?
2) 由于ISR不是可以被调度程序放入睡眠状态的“进程”类型。无论如何都必须完成?甚至没有任何时间片限制?如果ISR挂起,系统如何处理?
抱歉,如果问题很基础。我还没有深入研究这个主题。
谢谢,
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) 当前内核进程被挂起。但这里的“上下文”情况是什么?根据维基百科的描述,内核不会生成一个新的进程来运行ISR,并且“在中断处理开始时建立的上下文”,听起来非常像中断进程内的另一个函数调用。那么中断处理程序是否使用“中断进程”的堆栈(上下文)运行?还是内核会分配一些其他的内存空间/资源来运行它?
2) 由于ISR不是可以被调度程序放入睡眠状态的“进程”类型。无论如何都必须完成?甚至没有任何时间片限制?如果ISR挂起,系统如何处理?
抱歉,如果问题很基础。我还没有深入研究这个主题。
谢谢,