Trap
A trap is a synchronous exception — a deliberate or erroneous event inside the currently executing thread that forces the processor to transfer control to a privileged handler. Unlike an interrupt, which arrives from outside, a trap originates from the instruction stream itself: a system call instruction, a division by zero, a page fault, or an attempt to execute a privileged instruction from unprivileged code. The trap is the CPU's way of saying: you have crossed a line, and now you must answer to a higher authority.
Traps are the enforcement mechanism of the privilege ring architecture. When a process attempts to access memory outside its allocated space, the memory management unit triggers a page-fault trap. When it attempts to divide by zero, the arithmetic unit triggers a math-error trap. Each trap type has a dedicated handler in the kernel, and the transition is as expensive as an interrupt: context must be saved, privilege must be escalated, and the pipeline must be flushed. The difference is only the source of the event — internal rather than external.
The taxonomy of traps is not merely hardware taxonomy. It is a map of the boundaries that the operating system enforces. A page-fault trap is not a bug; it is the expected mechanism by which virtual memory systems load pages on demand. A system-call trap is not an error; it is the legitimate doorway into kernel services. The operating system does not merely react to traps. It relies on them. They are the nervous system of the machine, the mechanism by which the hardware informs the software that something needs attention.
See also: Interrupt, System Call, Privilege Ring, Virtual Memory, Operating System