Classifying an event as a hardware or software interrupt

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

Classifying an event as a hardware or software interrupt

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A user presses a key on the keyboard while a program is running. What type of interrupt is this?
A Software interrupt, because the signal comes from a program
B Hardware interrupt, because the signal comes from a device
2. A program tries to calculate 10 / 0 and the CPU cannot continue. What type of interrupt is this?
A Software interrupt, because the error happens in a running program
B Hardware interrupt, because the CPU cannot do the sum
3. The user moves the optical mouse across the desk. What type of interrupt is this?
A Hardware interrupt, because the mouse is a device sending a signal
B Software interrupt, because the cursor on screen is drawn by software
4. Two processes try to write to the same memory location at the same time. Which answer correctly classifies and justifies this?
A Hardware interrupt, because memory is a piece of hardware
B Software interrupt, because the clash is caused by programs that are running
5. Which sentence gives the best reason for classifying an event as a hardware interrupt?
A It is a hardware interrupt because the signal comes from a hardware device.
B It is a hardware interrupt because it happens while the computer is switched on.

Match the Pairs

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

Left columnRight column
1Pressing the 'A' key on the keyboard AHardware interrupt, because the signal comes from a hardware device (the keyboard)
2result = 10 / 0 BA key press is signalled by the keyboard device, so it is a hardware interrupt. The program that later uses the key does not create the signal.
3Moving the mouse sends a signal from a device, so it is a hardware interrupt CSoftware interrupt, because the signal comes from a running program causing a runtime error
4Two processes writing to the same memory location is a software interrupt because a running program causes the clash DDivide by zero is caused by a running program, so it is a software interrupt. Being handled by the CPU does not make it a hardware interrupt.
5Divide by zero = hardware interrupt, because it happens inside the CPU Esource = "mouse" # hardware interrupt
6Pressing a key = software interrupt, because the user typed it in a program Fwrite(addr, A) + write(addr, B) # software interrupt

Definitions

interrupt source

Fill in the Blanks

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

1.
IF source = "key press" THEN type ← "________" ENDIF
2.
IF source = "divide by zero" THEN type ← "________" ENDIF
3.
IF source = "mouse move" ____ type ← "hardware" ENDIF
4.
IF source = "memory clash" THEN ____ ← "software" ENDIF
5.
reason ← "a device sent the signal" OUTPUT "Hardware, _______ " + reason

Spot the Error

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

Question 1
A event ← "mouse moved"
B source ← "mouse"
C event ← "memory clash"
Question 2
A event ← "mouse moved"
B source ← "mouse"
C type ← "hardware"
D why ← "because of a program"
Question 3
A event ← "divide by zero"
B source ← "keyboard"
C type ← "software"
Question 4
A event ← "key pressed"
B source ← "running program"
C type ← "software"
Question 5
A event ← "divide by zero"
B source ← "running program"
C type ← "software"
D why ← "because from a device"

Answer Key

Classifying an event as a hardware or software interrupt
Section A: Quick Questions
Q1
B — Hardware interrupt, because the signal comes from a device
Q2
A — Software interrupt, because the error happens in a running program
Q3
A — Hardware interrupt, because the mouse is a device sending a signal
Q4
B — Software interrupt, because the clash is caused by programs that are running
Q5
A — It is a hardware interrupt because the signal comes from a hardware device.
Section B: Match the Pairs
Q1
Pressing the 'A' key on the keyboard → Hardware interrupt, because the signal comes from a hardware device (the keyboard)
Q2
result = 10 / 0 → Software interrupt, because the signal comes from a running program causing a runtime error
Q3
Moving the mouse sends a signal from a device, so it is a hardware interrupt → source = "mouse" # hardware interrupt
Q4
Two processes writing to the same memory location is a software interrupt because a running program causes the clash → write(addr, A) + write(addr, B) # software interrupt
Q5
Divide by zero = hardware interrupt, because it happens inside the CPU → Divide by zero is caused by a running program, so it is a software interrupt. Being handled by the CPU does not make it a hardware interrupt.
Q6
Pressing a key = software interrupt, because the user typed it in a program → A key press is signalled by the keyboard device, so it is a hardware interrupt. The program that later uses the key does not create the signal.
Section C: Definitions
Q1
interrupt source — The origin of the signal. From a device, like a key press or mouse move, it is a hardware interrupt. From a running program, like divide by zero or a memory clash, it is a software interrupt.
Section D: Fill in the Blanks
Q1
IF source = "key press" THEN type ← "hardware" ENDIF
Q2
IF source = "divide by zero" THEN type ← "software" ENDIF
Q3
IF source = "mouse move" THEN type ← "hardware" ENDIF
Q4
IF source = "memory clash" THEN type ← "software" ENDIF
Q5
reason ← "a device sent the signal" OUTPUT "Hardware, because " + reason
Section E: Spot the Error
Q1
C — The event is a mouse move, which comes from a device. A memory clash comes from a running program, so it does not match the source and type below. It should be "mouse moved".
Q2
D — The reason must match the source. A mouse move is a hardware interrupt because it comes from a device, not from a program. It should be "because of a device".
Q3
B — Divide by zero is an error caused by a running program, not by a keyboard. The source should be "running program", which makes it a software interrupt.
Q4
A — Two processes writing to the same memory location is a memory clash caused by programs. A key press comes from a device, so the event does not match the program source. It should be "memory clash".
Q5
D — Divide by zero comes from a running program, so the 'because' reason must say it is from a program, not a device. It should be "because from a program".