Interrupts Cambridge IGCSE Computer Science (9–1) revision

Not started

Learn it

In plain words

The processor is busy running a program when you press a key. How does it know? The keyboard sends an interrupt: a signal that says "something needs your attention".

It works like a teacher helping one student when another puts a hand up. The teacher finishes the sentence, notes where they were, deals with the question, and then goes back.

6 things to know

  1. An interrupt is a signal sent to the processor to tell it that something needs attention.
  2. Hardware interrupts come from devices: pressing a key on the keyboard, or moving the mouse.
  3. Software interrupts come from programs: a division by zero, or two processes trying to access the same memory location.
  4. Each interrupt has a priority. The processor finishes its current fetch–decode–execute cycle, then checks whether an interrupt is waiting and how urgent it is.
  5. If the interrupt has a higher priority than the current task, the processor saves what it was doing and runs the interrupt service routine (ISR) for that interrupt.
  6. When the routine has finished, the saved task is restored and carries on from where it stopped.

Worked example

A user presses a key while a program is running. Describe what happens.

  1. The keyboard generates an interrupt signal and sends it to the processor.
  2. The processor finishes the current fetch–decode–execute cycle, and checks the priority of the interrupt.
  3. If the priority is high enough, the current state of the program is saved.
  4. The interrupt service routine for the keyboard runs. Then the program's state is restored and it continues.

Tips and tricks

  • The processor finishes its current cycle before it checks for interrupts. It does not stop halfway through an instruction.
  • Know two examples of each kind. Hardware: a key press, a mouse movement. Software: division by zero, two processes wanting the same memory location.
5 questions, about 2 minutes.

It lands in your notebook with its questions as flashcards.

Interrupts: 5 questions and answers

These are the quiz’s questions. Do the quiz first, then come back here for the ones that got you.

  1. What is an interrupt?
    • an error that stops the computer for good
    • a signal telling the processor that something needs attention (the answer)
    • a type of memory
    • a program that the user writes

    It can come from hardware or from software.

  2. Which of these causes a hardware interrupt?
    • division by zero
    • pressing a key (the answer)
    • two processes accessing the same memory location
    • a loop that never ends

    The device sends the signal.

  3. Which of these causes a software interrupt?
    • moving the mouse
    • pressing a key
    • division by zero (the answer)
    • plugging in a printer

    The signal comes from a program.

  4. What does the processor run to deal with an interrupt?
    • a bootloader
    • an interrupt service routine (the answer)
    • a compiler
    • a spreadsheet

    There is a routine for each kind of interrupt.

  5. What happens to the task that was running when an interrupt is serviced?
    • It is deleted.
    • Its state is saved and it continues afterwards. (the answer)
    • It starts again from the beginning.
    • It is sent to the printer.

    Saving its state lets it carry on from where it stopped.

Still stuck on this one?Ask in the Papermunch Discord, or help someone else who is. Discord is for ages 13 and up.Join the server

Things you can type

Or go straight to

Or browse a shelf