Section 6 - System Interrupts
Computers provide a mechanism by which other modules may interrupt the normal processing sequence
- Some devices can be many orders of magnitude slower than the CPU
- Interrupts allow the CPU to work, pausing to service external devices only when they signal that they require attention
- The processor and operating system are responsible for suspending and resuming the user program appropriately
Common Classes of Interrupts
- Program
- e.g. overflow, division by zero
- Timer
- Generated by internal processor timer
- I/O
- An I/O controller signals operation completion
- Hardware Failure
- e.g. power failure, memory parity error
Flow Control
Consider a program which is intermittently required to write data
- This is done by a separate I/O program with its own preparation and completion operations
- Interrupts allow this to be done efficiently
- The main program may still be required to wait
Interrupt Cycle
As part of the instruction cycle the processor checks for an interrupt signal
- If there's no interrupt, fetch the next instruction
- If an interrupt is pending:
- Suspend execution of the current program and save its "state",
- Set the PC to the start address of the interrupt handler routine and process the interrupt,
- Restore the previous state and continue the interrupted program
Augmented Instruction Cycle
Multiple Interrupts
Approach 1: Disabled interrupts ( sequential )
- The processor ignores further interrupts whilst processing one interrupt
- Ignored interrupts remain pending and are checked after the first interrupts has been processed
- Interrupts are handled in the sequence as they occur
Approach 2: Define Priorities ( nested )
- Low priority interrupts can be interrupted by higher priority interrupts
- When the higher priority interrupt has been processed the processor returns to the previous interrupt
Summary
- Software allows a computer to execute different instructions without reconfiguring the hardware
- The meaning of the contents of Machine Word of memory is defined by the context in which it is used
- It pays to set slow external processes to run concurrently but to keep interrupts to check their status