The interrupt/anomaly/sink mechanism is the only way for the operating system to switch from user state to kernel state, which is the driving force of the operating system.
Interrupts and exception mechanisms have the following characteristics:
- Randomly occurring
- Automatic processing (Hardware completion)
- Can be restored
The difference between interrupts and exceptions:
- Interrupts are external events that are not expected by the running program
- Exception is thrown by an executing instruction
What are the roles of software and hardware during interrupts and exceptions:
- Hardware--Interrupt/exception response
- Software-Interrupt/exception handling program
Purpose of Interrupt/exception Introduction:
- Interrupts are introduced for parallel operation between the CPU and the device
- The introduction of the exception is to indicate that the CPU executes the instruction itself when the problem occurs
A story: Xiao Ming in Reading, suddenly came to a telephone, pick up the phone to continue reading, this is interrupted; Xiao Ming is reading, feeling thirsty, drinking water and then reading, this is abnormal.
|
Category |
Reason |
Synchronous/Asynchronous |
return behavior |
Interrupt |
Interrupt (interrupt) |
From an I/O device or other hardware part |
Asynchronous |
Always return to the next instruction |
Abnormal |
Caught (Trap) |
Consciously arranged. |
Synchronous |
Return to next instruction |
Fault (fault) |
Recoverable errors |
Synchronous |
Return to current instruction |
Terminate (Abort) |
Unrecoverable error |
Synchronous |
does not return |
Failure and fall into:
- Page fault, because it is fault, so when the page exception processing is completed, it will also try to re-execute the command that triggered the exception (most of the time is no longer a page fault)
- Breakpoint processing, used in debugging, encountered a breakpoint will stop to wait for your processing, wait until you let it re-execute, directly execute the next instruction
Finish
Operating system note One: interrupts, exceptions, and sink mechanisms