SLIDE 12 12
CPU Interrupt Handling
- Handling interrupts: relatively expensive
- CPU must:
– Save hardware state
- Registers, program counter
– Disable interrupts (why?) – Invoke via in-memory interrupt vector (like trap vector, soon) – Enable interrupts – Restore hardware state – Continue execution of interrupted process
Traps
- Special conditions detected by architecture
– E.g.: page fault, write to read-only page, overflow, system call
- On detecting trap, hardware must:
– Save process state (PC, stack, etc.) – Transfer control to trap handler (in OS)
- CPU indexes trap vector by trap number
- Jumps to address
– Restore process state and resume