Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

Interrupts and Traps

  • Most operating systems are implemented as interrupt-driven systems. Meaning the OS doesn’t run until some entity needs it to do something, the OS is woken up to handle a request.
  • System calls are implemented as special trap instructions that are defined as part of the CPU’s ISA.
  • Each system call is associated with a number. When an application wants to invoke a system call, it places the desired call’s number in a known location and issues a trap instruction to interrupt the OS. The trap triggers the CPU to stop executing its current instruction, and proceed execution the requesting application’s instruction.
  • Interrupts that come from the hardware layer, such as when a NIC receives data from the network, are typically referred to as hardware interrupts, or just interrupts. Interrupts that come from the software layer as the result of instruction execution, are known as traps.
  • Unlike system calls, hardware interrupts are delivered via the CPU’s interrupt bus. A device place’s a signal on the interrupt bus when it needs the CPU’s attention.
  • When the CPU is done handling an interrupt, it resumes processing it’s state before the interrupt occurred.