【Operating System Notes】Interrupt System

 

Program interruption:

In the process of executing the current program, there are some abnormal conditions or special requests that need to be handled urgently, the CPU temporarily
suspends the current program, and turns to process these abnormal conditions or special requests, after the processing is completed, the CPU automatically returns to the
current At the breakpoint of the program, continue to execute the original program.
 

 


work process:


1. Interrupt request: The interrupt source sends an interrupt request signal to the CPU.

Interrupt Request Flags:

The time each interrupt source issues an interrupt request to the CPU is random.

In order to record interrupt events and distinguish different interrupt sources, the interrupt system needs to set the interrupt request flag trigger INTR for each interrupt source.
When its state is "1", it means that the interrupt source has a request.
These flip-flops can form an interrupt request flag register , which is centralized in the CPU or scattered among various interrupt sources.

For external interrupts, the CPU sends an interrupt query signal to the interface at a unified time, that is, before the end of each instruction execution stage ,
to obtain an interrupt request of /0, that is, the CPU response time to the interrupt is in the execution stage of each instruction. end time .

(For instructions with long execution time, several query breakpoints can be set during execution)




2. Interrupt response :

The CPU must meet the following three conditions to respond to the interrupt:
(1) The interrupt source has an interrupt request (2) The CPU allows the interrupt to open the interrupt.
(3) An instruction has been executed, and there are no more urgent tasks.

Interrupt Arbiter: (Understand)

Hardware implementation: hardware queuer (through circuit design)

 Software Implementation: Query Program

Prioritization: (Understand)

1. Hardware fault interrupts belong to the highest level, followed by software interrupts; 2. Non-maskable interrupts are better than maskable interrupts;
3. DMA requests are better than interrupt requests transmitted by I/O devices; 4. High-speed devices are better than low-speed devices;
5 .The input is equipped with various excellent and dry output devices, 6. The real-time device is excellent and the ordinary device is dry.



3. Interrupt processing:

Interrupt implicit instruction:

①Turn off the interrupt. In the interrupt service routine, in order to protect the interrupt scene (that is, the contents of the CPU main register) from being interrupted by new interrupts, the interrupt must be turned off , so as to ensure that the interrupted program can be resumed correctly after the interrupt service routine is executed. Continue to execute
Save the breakpoint . In order to ensure that the original program can be correctly returned after the execution of the interrupt service routine, the breakpoint of the original program (ie, the content of the program counter (PC)) must be saved . It can be stored in the stack or in the specified unit.
1.
Lead out the interrupt service routine : take out the entry address of the interrupt service routine and transfer it to the program counter (PC)

software query method

hardware vector method

Advantage: The address of the service program can be changed, and the entry address can still be found
 


Interrupt Service Routine:

①Protect the scene
One is to save the program breakpoint (PC), which has been completed by the interrupt hidden instruction;
the other is to save the contents of the general register and the status register. Stacks can be used, or specific memory cells can be used.
②Interrupt service [device service]
main part
③Restore the scene
Send the previously saved information back to the register through the pop instruction or fetch instruction ④Interrupt
return
Return to the original program breakpoint through the interrupt return instruction


Single interrupt: do not respond to new interrupt requests when executing interrupt service routines
Multiple interrupts: also known as interrupt nesting, can respond to new interrupt requests when executing interrupt service routines
 

 

Interrupt masking technology is mainly used for multiple interrupts. To have the function of multiple interrupts, the CPU must meet the following conditions.
①Set the open interrupt instruction in advance in the interrupt service routine
②The interrupt source with high priority has the right to interrupt the interrupt source with low priority
Each interrupt source has a screen as a trigger, 1 means the request of the interrupt source on the screen, 0 It means that the application can be applied normally. All the mask
triggers are combined together to form a mask word register. The content of the mask word register is called the mask word.


 

 

Guess you like

Origin blog.csdn.net/m0_52043808/article/details/123949325