Definition: A reaction by the CPU to an event that occurs in the system. The CPU pauses a program in progress, then automatically switches to the appropriate handler, and then returns to the breakpoint to resume execution of the interrupted program.
System interrupt: After an interrupt occurs in an interrupt system, the system stops responding and performs an interrupt response. This process is called system interrupt.
Interrupts can be divided into three categories:
One class: caused by the EXTERNAL CPU, called interrupt, such as I/O interrupt, clock interrupt, console interrupt. Type 2: it is a process caused by internal events from the CPU or events in program execution. It is called an exception. For example, the process is caused by CPU fault (power supply voltage is lower than 105V or frequency is outside 47~63Hz), program fault (illegal opcode, address out of bounds, floating point overflow, etc.). Class 3: the process caused by the use of a system call requesting a system service in the program, called “trap”. The first two types are often referred to as interruptions, and they tend to occur unintentionally and passively, while falling in is intentional and active
Interrupt processing: Interrupt processing is generally divided into interrupt response and interrupt processing two steps. Interrupt response is implemented by hardware, interrupt processing is mainly implemented by software.
Interrupt response: The whole processing process of interrupt request is implemented by a set of interrupt mechanism formed by combining hardware and software. When an interrupt occurs, the CPU pauses execution of the current program while the zone handles the interrupt. The process by which hardware responds to an interrupt request is called an interrupt response. Generally speaking, the interrupt response performs the following three steps in order
1. Stop the execution of the current program; 2. Save the original program breakpoint information (mainly program counter PC and program status register PS content); 3. Take out the interrupt vector from the interrupt controller and go to the corresponding handler.
Usually, the CPU checks for interrupt requests immediately after executing an instruction. If yes, respond immediately.
When an interruption occurs, the system responds, whether from hardware (such as from a clock or external device), programmatic interrupts (executing instructions that cause “Software interrupts” — Software Interrupts), or unexpected events (such as accessing a page out of memory). If the execution of the current CPU priority is lower than the interrupt priority, so it is suspended for the current program of instruction execution, receives the interrupt, and upgrade the execution of processing level (usually the same as the interrupt priority level), so that in the current CPU is interrupted, to screen out interrupt other at the same level or lower, then save the breakpoint information, The incoming interrupt vector goes to the entry of the responding interrupt handler.