首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

中断(Interrupt)与异常(Exception)

中断(Interrupt)与异常(Exception)

From <Intel 80386 Programmer's Reference Manual 1986>

The 80386 has two mechanisms for interrupting program execution:
1. Exceptions are synchronous events that are the responses of the CPU
to certain conditions detected during the execution of an instruction.
2. Interrupts are asynchronous events typically triggered by external
devices needing attention.
在IA32架构上, 中断是异步事件, 是硬件设备通过中断控制器对CPU发出的中断请求. 异常是同步事件, 由系统本身检测到,  如断点指令INT 3, 以及一些软件执行异常如除0等. 中断和异常门都放在IDT中, 其中中断的type字段是0xFF, 而异常是0xFE. 当中断发生后, CPU会自动对中断允许标志位IF(Interrupt Flag)设置以禁止中断, 在中断执行结束后会自动复位, 而异常不会, 这是两者在实现层面最主要的区别. 当发生中断或异常是, 标志位TF(Trap Flag)都会被设置.

IA32架构支持任意深度的中断嵌套:
Interrupts and exceptions can cause task switches (if needed in the
system design). The processor not only switches automatically to the
task that handles the interrupt or exception, but it automatically
switches back to the interrupted task when the interrupt or exception
has been serviced. Interrupt tasks may interrupt lower-priority
interrupt tasks to any depth.
继承事业,薪火相传
返回列表