Interrupt Types and Sources
What You'll Learn
You'll learn how to distinguish between hardware interrupts, software interrupts (traps), and exceptions, and recognize where each type originates.
The Three Categories of Interrupts
Not all interrupts are created equal. The operating system must handle signals from different sources, each requiring different responses.
Hardware Interrupts
These come from physical devices outside the CPU. When your keyboard, disk drive, network card, or timer needs the CPU's attention, it sends a hardware interrupt signal through the interrupt controller.
Common sources:
- Timer chips (for scheduling)
- Disk controllers (I/O completion)
- Network interface cards (packet arrival)
- Keyboard/mouse (user input)
Software Interrupts (Traps)
These are intentionally triggered by programs through special instructions. When you make a system call, the program executes a trap instruction to request OS services. Unlike hardware interrupts, traps are synchronous—they happen at predictable points in program execution.
Common sources:
- System call requests (
int 0x80orsyscallinstructions) - Debugging breakpoints
Exceptions
These are error conditions detected by the CPU itself during instruction execution. They're synchronous like traps but involuntary—the program didn't mean to cause them.
Common sources:
- Division by zero
- Invalid memory access (page fault)
- Illegal instruction opcodes
- Arithmetic overflow
Think of it like notifications: hardware interrupts are like doorbell rings (external), traps are like you calling customer service (intentional), and exceptions are like smoke alarms (internal error detection).
Key Takeaway: Hardware interrupts come from devices, software interrupts (traps) are intentional program requests, and exceptions signal CPU-detected errors—each requires different handling by the operating system.