当前位置:网站首页>x86 Exception Handling and Interrupt Mechanism (3) Interrupt Handling Process

x86 Exception Handling and Interrupt Mechanism (3) Interrupt Handling Process

2022-08-09 11:15:00 XV_

After finishing the process of finding the interrupt service routine according to the interrupt type number in the previous section, let's focus on explaining the more complete process of interrupt handling.

This section takes the interrupt processing process of the 8086 era as an example to illustrate, mainly divided into two parts

  • Hardware processing
  • Software processing

It should be noted that this is not absolute, it depends on the actual situation. In short, if the hardware has already completed the necessary actions, the interrupt service routine does not need to be executed. If not, it needs to be written into the program to executerelated operations.

1 Interrupt process

1.1 Prerequisite: Generate & Detect Interrupt

Insert picture description here
The premise of interrupt processing is to generate an interrupt and then detectTo interrupt, otherwise how to deal with it?

For the generation of interrupts, it is divided into internal and external. The internal is generated by the execution of the instruction. I will not say the specifics. There are also external ones. Generally, special peripherals such as power failure cannot be shielded. Other peripheralsSuch as the mouse and keyboard, through the interrupt controller such as 8259A to generate external interrupts.

As for the detection of interrupts, internal interrupts generally have related hardware that can directly detect and release a certain signal, while external interrupts depend on some register flag bits and the like, depending on the situation.

1.2 Interrupt Handling

insert image description hereInsert picture description hereThe division of labor between software and hardware is not absolute. We need to analyze the actual situation. If the hardware is done, the software is not needed.If it is done, the software must be done if the hardware is not done.

insert image description here

Hardware processing

insert image description here

Software processing

insert image description here

Interrupt handling is similar

  • Interrupt generated, interrupt detected
  • Protect the scene
  • Find the corresponding interrupt service routine
  • Execute interrupt handler
  • Restore site
  • Return to continue execution

In addition, the interrupt service routine itself is also a program that may generate interrupts during its execution, that is, interrupt nesting, which depends on the interrupt switch, the specificThe details depend on the implementation, not necessarily.

All in all, through a series of abstractions, we can only obtain the rough process of interrupt processing. The actual process is closely related to the actual situation, and the situation is changeable, which requires more use and practice.

原网站

版权声明
本文为[XV_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208091103199154.html