Interrupts

Hardware interrupts, software interrupts and exceptions, how an interrupt is handled, the vector, the context, masking, and the choice between polling and interrupts.

  • 23 cards
  • 4 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. Scenarios

A few cards from the deck

  • Interrupt: what is it?

    Show the answer

    A signal that asks the processor to suspend the running program to handle an event right away, then resume.

    The processor does not have to watch the keyboard or the network all the time: the device warns it when something happens.

  • An interrupt arrives in the middle of a division instruction. What does the processor do?

    • It finishes the current instruction, then takes the interrupt
    • It abandons the instruction and replays it from the very beginning later
    • It ignores the interrupt until the end of the previous routine
    • It cuts the instruction in two and keeps half for later
    Show the answer

    It finishes the current instruction, then takes the interrupt

    The processor only looks at interrupts between two instructions. The machine is therefore never in a half-computed state when the handler runs.

  • An … is triggered by the processor itself, because of the instruction being run: division by zero, invalid address.

    Show the answer

    An exception is triggered by the processor itself, because of the instruction being run: division by zero, invalid address.

    It is synchronous with the program, unlike a hardware interrupt that comes from a device at an unpredictable moment.

  • Interrupt handler: what is it?

    Show the answer

    A small program run in response to one specific interrupt, which deals with the event then hands control back to the interrupted program.

    It must be short: while it runs, other events may wait or be lost. It records the event; the bulk of the work is done later.

  • A microcontroller refreshes a screen in its main loop and reads its button only once per pass. Short presses are missed. Which fix is right?

    • Wait a few milliseconds after each read of the button
    • Wire the button to an interrupt whose handler records the press
    • Mask every interrupt during the refresh
    • Read the button twice per pass instead of once
    Show the answer

    Wire the button to an interrupt whose handler records the press

    With polling, a press shorter than the loop falls between two reads. An interrupt reacts at once, even in the middle of the refresh. Reading twice only reduces the risk; waiting after each read lengthens the loop and makes it worse.