Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the five stages of interrupt handling in a computer program?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you what are the five stages of the computer program interrupt processing process, I hope you will gain something after reading this article, let's discuss it together!

There are five stages in the process of interrupt processing: 1, interrupt request stage; 2, interrupt decision stage, there are two methods: hardware judgment and software judgment; 3, interrupt response stage, CPU sends interrupt response signal to interrupt source; 4, interrupt service stage; 5, interrupt return phase, return to the breakpoint of the original program, restore the hardware site, and continue to execute the original program.

The operating environment of this tutorial: windows7 system, Dell G3 computer.

The basic process of interrupt processing includes five stages: interrupt request, interrupt decision, interrupt response, interrupt service and interrupt return.

1. Interrupt request phase

1) the interrupt (internal interrupt) that occurs within the CPU does not require an interrupt request, and the interrupt control logic within the CPU receives and processes directly.

2) the external interrupt request is made by the interrupt source. The external interrupt source uses the interrupt input pin of the CPU to input the interrupt request signal. Generally, CPU has two interrupt request input pins: masked interrupt request input pin and unshielded interrupt request input pin.

1.1 interrupt request trigger

The time at which each interrupt source sends an interrupt request signal is uncertain, and so is when the CPU responds to the interrupt. Therefore, each interrupt source has an interrupt request trigger that locks its own interrupt request signal and holds it until the CPU responds to the interrupt request.

1.2 interrupt allow trigger

Inside CPU, there is an interrupt allow trigger that, when it is "1", allows CPU to respond to interrupts, called open interrupts. If it is "0", CPU is not allowed to respond to interrupts, and interrupts are shielded, which is called off interrupts.

%% usually, when the CPU is reset, the interrupt allows the trigger to also reset to "0", that is, the interrupt is off. When the CPU interrupt responds, the CPU automatically turns off the interrupt, prohibiting the acceptance of another new interrupt.

%% interrupt allows the state of the trigger to be set with on or off interrupt instructions.

two。 Interruption decision stage

CPU can only accept requests from one interrupt source at a time. When multiple interrupt sources request to CPU at the same time, CPU must find out the interrupt source with the highest interrupt priority. This process is called interrupt optimization.

Interrupt can be judged by either hardware method or software method.

2.1 Software Excellence

After CPU detects the interrupt request, it first reads the contents of the interrupt request register, detects their status bit by bit, detects that a certain bit is 1, determines that the corresponding interrupt source has an interrupt request, and transfers to execute its interrupt service program.

Which one is detected first will have a high priority, and then which one will have a low priority, and the order of detection is the priority order of each interrupt source.

Assume that the port address entered in the figure above is 87FFH. The inquiry procedure is as follows:

MOV DX, 87FFH

IN AL, DX; read interrupt request register contents

SHR AL, 1

JC IR0; IRQ0 has a request, transfer to IR0

SHR AL,1

JC IR1; IRQ1 has a request, transfer to IR1

SHR AL,1

JC IR2; IRQ2 has a request, transfer to IR2

... ...

It takes a long time for software to determine the best result. If there are many interrupt sources, the real-time performance of the interrupt is very poor, but the software priority arrangement is flexible.

2.2 hardware decision

There are two common ways to determine the priority of interruption source by using special hardware circuit: daisy chain circuit and interrupt controller.

2.2.1 Daisy chain decision circuit

Design idea: each interrupt source has an interrupt logic circuit, and all interrupt logic circuits form a chain, just like a daisy chain. The interrupt source at the front of the chain has the highest priority, and the later the device, the lower the priority.

The realization process: CPU receives the interrupt request, if the interrupt is allowed, CPU sends out the interrupt response signal. The interrupt response signal first arrives at the front end of the daisy chain. If interrupt source 1 makes an interrupt request, it will intercept the interrupt response signal and block it so that it cannot be transmitted to the next interrupt source. Whether the following interrupt sources have made interrupt requests or not, it is impossible to receive interrupt response signals, so their interrupt requests cannot be responded to.

2.2.2 interrupt controller optimization

Interrupt controllers, such as Intel8259A, can set the interrupt priority of the interrupt source in a number of ways. There is an interrupt priority discriminator in the interrupt controller, which automatically identifies the interrupt source with the highest priority of the interrupt request, and sends its interrupt vector code to the data bus. CPU receives the interrupt vector code and finds its interrupt service program accordingly.

3. Interrupt response phase

After interrupt judgment, interrupt processing enters the interrupt response stage. When an interrupt responds, CPU sends an interrupt response signal to the interrupt source, and at the same time:

① protects hardware site

② off interrupt

③ protection breakpoint

④ obtains the entry address of the interrupt service program.

4. Interruption service phase

The general structure of the interrupt service program is:

1) protect the scene. A number of instructions are arranged at the beginning of the interrupt service program, and the contents of each register are pressed into the stack to save.

2) start and interrupt. During the execution of the interrupt service program, higher-level interrupt requests are allowed to interrupt the current interrupt service program to achieve interrupt nesting.

3) interruption of service. Complete the specific requirements of the interrupt source.

4) restore the scene. Before the end of the interrupt service program, the interrupt site of the main program must be restored. Usually, the field information saved in the stack is popped into the original register.

5) interrupt return. Return to the breakpoint of the original program and continue to execute the original program.

5. Interrupt return phase

Return to the breakpoint of the original program, restore the hardware site, and continue to execute the original program.

The interrupt return operation is the reverse process of the interrupt response operation.

After reading this article, I believe you have a certain understanding of "what are the five stages of computer program interrupt handling process". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for your reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report