Interrupt
- Tags
- comp-arch
Is a means of communication between the CPU and the OS kernel.
Source | Description |
---|---|
CPU | Exceptions such as divide by zero or page faults. |
Devices | Hardware interrupts such as input being available. |
CPU instruction | Traps such as syscalls or breakpoints. |
It's the operating systems job to watch for interrupts. Each interrupt should have an interrupt handler that stashes away any data associated with it until it can be processed. A keyboard for example raises a hardware interrupt for every key-press and the OS stores this interrupt data near the bottom of memory where the active process can read from it when control switches back to it.
Software interrupts (AKA software faults) are interrupts passed directly to processes by the Operating System.
Interrupts generally have an associated priority level. Low priority interrupts, such as keyboard events, have to wait on higher priority interrupts like clock ticks or disk events.
Unix is designed to give high priority to the kinds of events that need to be processed rapidly in order to keep the machine's response smooth.