When hardware interrupts arrive (keyboard, mouse, network), the CPU needs to know what to do. Without an interrupt handler, the interrupt would be ignored or crash the system.
The OS interrupt handler is a function that runs when a hardware interrupt fires. It reads the scan code (for keyboard) or data (for other devices) and dispatches it to the appropriate driver or application.
- Interrupt fires: Hardware raises IRQ (e.g., IRQ 1 for keyboard)
- CPU jumps: Looks up handler in Interrupt Vector Table
- Handler runs:
- Read data from device (scan code from keyboard)
- Convert to character (
g= scan code 0x22) - Determine target application (active window = browser)
- Deliver event: Send key event to application
- Interrupt Vector Table maps IRQ numbers to handler functions
- Handlers run in kernel mode (privileged)
- Must be fast—blocking handler blocks entire system
- After handler, CPU resumes previous task
- Built from: Keyboard Interrupt — handler processes keyboard IRQs
- Builds into: Browser Autocomplete — key events go to browser
- Related: Interrupt Vector Table — lookup table for handlers
- Related: Kernel Mode — handlers run with full privileges
- Slow handlers cause system lag (handler blocks everything)
- Nested interrupts require careful handling
- Missing handler = interrupt ignored (or panic)
- Shared IRQs (multiple devices on one IRQ) need demultiplexing