(This is the older material - click here - for current specification content)

4. What happens in the CPU

We have just said that 'An interrupt is a signal for the CPU to stop what it is doing and instead carry out the interrupt task, once the task is complete, the CPU goes back to what it was doing'.

But what is meant by 'back to what it was doing'?

To appreciate this, you need to understand a little about what goes on inside a CPU

A CPU contains a number of 'registers'. A register is a small section of on-chip memory having a specific purpose. Registers range from 8 bits wide on an 8 bit CPU to 64 bits and beyond.

Registers in the CPU hold all of the data currently being handled. These include

  • The current instruction being executed (Instruction Register),
  • The location in primary memory of the next instruction (Program Counter)
  • A number of general purpose registers holding current data

The registers are updated by each tick of the system clock so at any instant in time, they hold specific values.

When an interrupt comes along, all the register values are copied to a special data structure or memory area called the 'stack' which is in primary memory. And they stay in the stack whilst the CPU starts executing the interrupt service routine (ISR). Once the routine is over, the registers are loaded back with their original values from the stack and can continue with what they were doing before the interrupt came along.

This jumping of instructions from current CPU operations to the ISR and then back again is called 'context switching'

The movie clip below shows that the CPU has a number of internal memory slots called 'registers' and their content can change with every tick of the CPU clock. By being able to temporarily store their entire content for a moment allows a CPU to carry out a task and then easily switch back to what it was doing.

 

Operation of a CPU

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: CPU Registers

 

 

 

 

Copyright © www.teach-ict.com