Interrupts
An interrupt is a signal from a device to the CPU.

Hardware may send interrupts...

  • a printer may send an interrupt when it needs more data to be sent or if an error occurs (eg Out of paper)
  • the timer in the processor may send an interrupt at regular intervals to perform certain functions.
  • a malfunctioning device may send an interrupt

Software may send interrupts...

  • some runtime errors (such as 'division by zero') will generate an interrupt.
  • some specific functions may be performed by sending an interrupt to the operating system. 

There is a special register in the CPU called the interrupt register. When an interrupt occurs one of the bits is set to 1 - each bit (flag) represents a different type of interrupt. The processor will check this flag regularly to see if any interrupts have occurred. 

When the CPU receives an interrupt request (IRQ) ...

  • the program currently being executed is halted, and the contents of all the registers are saved,
  • an interrupt service routine is run which deals with the interrupt.
  • the original program is continued from where it left off..

There may be more than one interrupt occurring at the same time. There is a priority associated with each interrupt and the processor will service the interrupt with the highest priority first. A high-level interrupt may interrupt the service of a lower level interrupt.

Priority levels may depend on...

  • the importance of the requesting device to the running of the computer
  • the length of time it takes to service the interrupt

Eg Hardware failure would have a high priority....printer out of paper would be a low priority.