Once an interrupt has occurred, what does the CPU do with it? For each interrupt the CPU must run some code specified by the OS. In order to do this the CPU has a vector of memory addresses for each interrupt.

Interrupt name

Interrupt mask

Address to look in

Address of interrupt code

I/O

0000 0001

1000 0000

1000 1000

Hardware failure

0000 0010

1000 0001

1100 1000

 

The CPU looks into the vector, which is stored somewhere in memory. It will then jump to the address stored in that vector. In the above case we have two interrupts, a hardware failure and a I/O.

  • The CPU chooses the hardware failure interrupt as it has a higher priority
  • The CPU looks into the vector at address 1000 0001
  • The CPU places the current program counter onto the stack
  • The CPU then loads the contents of address 1000 0001 into the program counter
  • The CPU continues execution at 1100 1000

The OS will store code at these memory addresses to handle the interrupt. The hardware failure may result in a dialog box being popped up for the user to inform them of the failure. Once the CPU has finished it will pop the stack and restart execution from the previous program counter position.