HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
The Operating System and Interrupts
  1. 1What an operating system does
  2. 2Interrupts and where they come from
  3. 3Handling an interrupt
  1. Computer Science
  2. /The Operating System and Interrupts
  3. /Interrupts and where they come from

Course 4.2·Lesson 2 of 3

Interrupts and where they come from

An interrupt is a signal to the processor that something needs attention now. Hardware interrupts come from devices, such as a key press or a mouse movement. Software interrupts come from programs, such as a division by zero or two processes trying to use the same memory location.

about 25 min1 simulation1 practice question
Lesson 2 of 3Show all lessonsHide
The Operating System and Interrupts
  1. 1What an operating system does
  2. 2Interrupts and where they come from
  3. 3Handling an interrupt

Try the code and the simulations beside the lesson.

A tap on the shoulder

You are reading a book, and a friend taps your shoulder to ask a question. You mark your page, answer, and go back to reading. An interrupt works the same way. It is a signal sent to the processor to say that something needs its attention now.

Why not just let the processor look at each device again and again to see if it needs anything? It would waste a lot of time checking devices that have nothing to say. With interrupts, the processor gets on with its work, and each device or program signals when it needs something.

How an interrupt is generated

An interrupt is generated (made) when a device or a program needs the processor. The signal goes to the processor, which deals with it at the end of the instruction it is carrying out. There are two kinds, by where the signal comes from.

A box labelled Processor on the right. On the left, two groups send arrows to it. The hardware group has a keyboard (a key is pressed) and a mouse (the mouse is moved). The software group has a program (division by zero) and two processes (both try to access the same memory location). The arrows are labelled interrupt signal.

Hardware interrupts

A hardware interrupt comes from a device. The syllabus gives two examples:

  • pressing a key on the keyboard: the keyboard signals that a key is ready to be read;
  • moving the mouse: the mouse signals that the pointer must move.

Other devices send hardware interrupts too. A printer can signal that it has run out of paper.

Software interrupts

A software interrupt comes from a program, often because something has gone wrong. The syllabus gives two examples:

  • division by zero: a program tries to divide a number by zero, which has no answer;
  • two processes trying to access the same memory location: two running programs try to use the same place in RAM at once.

A process is a program while it is running.

How to tell them apart

Ask where the signal starts.

  • From a piece of hardware, such as a keyboard, a mouse or a printer? A hardware interrupt.
  • From the instructions of a program? A software interrupt.

A key press is a hardware interrupt, even though a program then uses the key. The signal starts at the keyboard.

How many interrupts?

In the model below, each key press sends one interrupt. Even slow typing gives the processor many interrupts to handle.

Practise with new numbers

Try it in Python

The program stores four events with their kind, prints them and counts the hardware interrupts.

Read it first. Then run it. Are the two kinds printed in the order you expected?

1. Add ("the printer runs out of paper", "hardware"), to the list. Predict the new count, then run it.

Common mistakes

  • Calling a key press a software interrupt because a program reads the key. The signal comes from the keyboard, a device.
  • Calling a division by zero a hardware interrupt because the processor does the sum. The signal comes from the instructions of the program.
  • Saying an interrupt switches the computer off. It only makes the processor stop its task for a moment.

Remember these

  • An interrupt is a signal to the processor that something needs attention now.
  • Hardware interrupts come from devices: pressing a key, moving the mouse.
  • Software interrupts come from programs: division by zero, two processes trying to access the same memory location.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. What is an interrupt?
  1. Is moving the mouse a hardware interrupt or a software interrupt?
  1. A program calculates the average of an empty list and divides by zero. What kind of interrupt is this?
  1. Give the second software interrupt example from the syllabus.
  1. Why are interrupts better than the processor checking every device again and again?

Enroll free in The Operating System and Interrupts

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (2)

Here are six events on a computer. A: A key is pressed on the keyboard…Easy · High School (9–10) · by StemPy Lab
In a model, each key press sends one hardware interrupt to the processor…Medium · High School (9–10) · by StemPy Lab
Next: lesson 3Handling an interrupt
← The Operating System and Interrupts
← What an operating system doesHandling an interrupt →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.