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

Interrupts and Buffers

Interrupts

  • An interrupt is a signal sent from a device (hardware) or a program (software) to the microprocessor.
  • It alerts the processor that a specific event requires immediate attention.
  • The processor temporarily suspends execution of its current task and saves the status of the current task to memory.
  • The processor then executes a specialized program called an Interrupt Service Routine (ISR) to handle the request.
  • Once completed, the processor resumes the original task exactly where it left off.

Causes of interrupts

  • Timing signals: Hardware timers alerting the CPU to switch between concurrent software processes.
  • I/O processes: A disk drive or network interface signaling that it has finished reading/writing data and is ready for the next command.
  • Hardware faults: Critical component errors, such as a printer experiencing a physical paper jam.
  • User interaction: Manual key presses input by the user.
  • Software errors: Severe exceptions triggered by application logic bugs, such as an attempt to execute a division-by-zero operation or loading a non-existent file path.

Hardware management (buffer and interrupt sequence)

  • A printer will be used as the example.

Fetch-execute cycle

  • The microprocessor contains a dedicated Interrupt Register. This register is systematically checked bit-by-bit at the very end of each Fetch-Execute cycle.
  • If a bit transitions (e.g. from 0000 to 1000), an interrupt has been flagged.
  1. The CPU identifies the level of interrupt priority.
  2. If the interrupt has a higher priority than the current task, the CPU suspends execution.
  3. The current contents of the Program Counter (PC) and working data registers are saved securely to physical memory.
  4. The CPU loads the start address of the appropriate Interrupt Service Routine (ISR) into the PC.
  5. The ISR executes to handle the task, the interrupt flag register bit is reset, and the saved register states are reloaded to resume the original process exactly where it left off.

Diagram