How an interrupt is generated

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

How an interrupt is generated

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What starts the process of generating an interrupt?
A An event happens that needs the CPU's attention
B The CPU deletes the running program
2. Which is the interrupt signal sent to?
A The monitor
B The CPU
3. A key is pressed on the keyboard. Which source generates the interrupt?
A Software (a running program)
B Hardware (the keyboard)
4. A running program tries to divide a number by zero. Which source generates the interrupt?
A Software (the running program)
B Hardware (the keyboard)
5. Worked example: a key is pressed. What is the correct order of the first two steps?
A Key is pressed, then the keyboard sends an interrupt signal to the CPU
B The keyboard sends an interrupt signal to the CPU, then the key is pressed

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1interrupt signal Adivide by zero error -> interrupt signal
2keyboard sends signal Bkey pressed -> signal -> CPU
3A running program is a software source that can generate an interrupt when an error happens CAn interrupt is only generated after an event happens, so the signal cannot be sent before the key press.
4The order of events when a key is pressed: event, signal, then the CPU is told DA signal sent to the CPU by a device or a running program to report an event that needs attention
5CPU -> interrupt signal -> keyboard EA hardware source generates an interrupt when a key is pressed
6interrupt signal sent before the key is pressed FThe direction is wrong: the device sends the interrupt signal to the CPU, not the CPU to the device.

Definitions

interrupt signal

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
event ← "key press" SEND ________________ TO CPU
2.
IF event = "key press" THEN SEND interrupt signal TO ___ ENDIF
3.
device ← keyboard source ← ________
4.
IF divisor = 0 THEN source ← ________ ENDIF
5.
__ event = "key press" THEN SEND interrupt signal TO CPU ENDIF

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A IF key is pressed THEN
B keyboard creates signal
C SEND interrupt TO printer
D ENDIF
Question 2
A result <- 10 / 0
B error <- TRUE
C source <- 'software'
D SEND interrupt TO the mouse
Question 3
A type <- 'software'
B source <- 'mouse'
C event <- 'button clicked'
D SEND interrupt TO CPU
Question 4
A EVENT: user presses a key
B keyboard detects the key
C SEND interrupt signal TO CPU
D CPU never learns of the event
Question 5
A user presses a key
B keyboard creates a signal
C signal is sent to the screen
D CPU may now handle the key

Answer Key

How an interrupt is generated
Section A: Quick Questions
Q1
A — An event happens that needs the CPU's attention
Q2
B — The CPU
Q3
B — Hardware (the keyboard)
Q4
A — Software (the running program)
Q5
A — Key is pressed, then the keyboard sends an interrupt signal to the CPU
Section B: Match the Pairs
Q1
interrupt signal → A signal sent to the CPU by a device or a running program to report an event that needs attention
Q2
keyboard sends signal → A hardware source generates an interrupt when a key is pressed
Q3
A running program is a software source that can generate an interrupt when an error happens → divide by zero error -> interrupt signal
Q4
The order of events when a key is pressed: event, signal, then the CPU is told → key pressed -> signal -> CPU
Q5
CPU -> interrupt signal -> keyboard → The direction is wrong: the device sends the interrupt signal to the CPU, not the CPU to the device.
Q6
interrupt signal sent before the key is pressed → An interrupt is only generated after an event happens, so the signal cannot be sent before the key press.
Section C: Definitions
Q1
interrupt signal — A signal sent to the CPU by a device (hardware) or a running program (software) when an event, such as a key press, needs the CPU's attention.
Section D: Fill in the Blanks
Q1
event ← "key press" SEND interrupt signal TO CPU
Q2
IF event = "key press" THEN SEND interrupt signal TO CPU ENDIF
Q3
device ← keyboard source ← HARDWARE
Q4
IF divisor = 0 THEN source ← SOFTWARE ENDIF
Q5
IF event = "key press" THEN SEND interrupt signal TO CPU ENDIF
Section E: Spot the Error
Q1
C — An interrupt signal is sent to the CPU, not to the printer. The line should be SEND interrupt TO CPU.
Q2
D — The running program reports its error by sending the interrupt signal to the CPU. The mouse does not receive it. It should be SEND interrupt TO CPU.
Q3
A — A mouse is a hardware device, so the interrupt it generates is a hardware interrupt. It should be type <- 'hardware'.
Q4
D — The interrupt signal exists to tell the CPU about the event so it can give it attention. The CPU is alerted, not left unaware.
Q5
C — The interrupt signal from the keyboard goes to the CPU, not to the screen. It should be signal travels to the CPU.