Interrupt means that during the operation of a computer, when some unexpected situation requires the intervention of the host computer, the machine can automatically stop the running program and switch to the program to deal with the new situation, and then return to the original suspended program to continue to run after the completion of the process.
The interrupt flow chart is as follows:
Interrupt process
In accordance with the order of events, the interrupt process includes:
①Interrupt source sends out the interrupt request;
②Judge whether the current processor allows interruptions and whether the interrupt source is blocked;
③Priority queuing;
④Processor execution of the current instruction or the current instruction can not be executed, and the interrupt source is blocked. instruction or the current instruction can not be executed, then immediately stop the current program, protect the breakpoint address and the current state of the processor, and transfer to the corresponding interrupt service program;
⑤ Execute the interrupt service program;
⑥ Restore the state of the protected state, and execute the "interrupt return" instruction to go back to the program that has been interrupted or transfer to other programs. The program is not a program that can be used as an interruptor.
The first four operations in the above process are done by hardware, and the last two are done by software.
Extended Information
It is well known that processor speeds are often not on the same order of magnitude as the speed of peripheral hardware devices, so if the kernel takes the approach of having the processor make a request to the hardware and then wait specifically for a response, it obviously reduces kernel efficiency.
Since the hardware is so slow to respond, the kernel should take care of other business in the meantime, waiting until the hardware has actually completed the requested operation before going back to it. To accomplish this, polling might be a solution. It would allow the kernel to periodically query the state of the device and then process it accordingly.
But this approach is likely to make that kernel do a lot of useless work, because polling will always be repeated periodically, regardless of whether the hardware device is busy completing its task or has already completed its work. A better approach would be for us to provide a mechanism for the hardware to signal the kernel when it needs to (turning kernel-initiated into hardware-initiated), which is called an interrupt mechanism.
Interrupts allow the hardware to communicate with the processor. For example, when you hit the keyboard, the keyboard controller (the hardware device that controls the keyboard) sends an interrupt to notify the operating system that a key has been pressed. An interrupt is essentially a special electrical signal that is sent from the hardware device to the processor.
The processor receives the interrupt and immediately reflects the arrival of this signal to the operating system, which then takes care of processing the newly arrived data. Hardware devices generate interrupts without regard to synchronization with the processor's clock - in other words, interrupts can be generated at any time. As a result, the kernel can be interrupted at any time by a newly arriving interrupt.
Different devices correspond to different interrupts, and each interrupt is identified by a unique number. Thus, an interrupt from the keyboard is distinct from an interrupt from the hard disk, allowing the operating system to distinguish between interrupts and know which hardware device generated which interrupt. This allows the operating system to provide different interrupt handlers for different interrupts.
If another event occurs while it is executing a program (for example, the user opens another program) then this is handled by the computer system's interrupt mechanism.
The interrupt mechanism consists of the hardware interrupt device and the interrupt handling service program of the operating system.
Let the hardware then signal the kernel when needed.
Baidu Encyclopedia - Interrupt Mechanism
Baidu Encyclopedia - Interrupt