OS & Hardware

What is the usual sequence when a CPU accepts an interrupt?

  1. AIt discards the running program and restarts it from the beginning
  2. BAfter running the interrupt handler, it starts the next program rather than returning
  3. CIt saves the current location and state, runs the interrupt handler, then returns to the saved location
Show answer and explanation

Answer: C. It saves the current location and state, runs the interrupt handler, then returns to the saved location

On accepting an interrupt, the CPU saves the address of the instruction it would have executed next plus state such as the operating mode, and jumps to the interrupt handler, located for example via an interrupt vector table. The handler saves the registers it uses, does its work, restores state and resumes the original program where it stopped. Programs are not discarded or restarted. The OS may switch to another process after the handler, but that is a scheduling decision.

  • A. Programs are never discarded.
  • B. It normally returns; switching processes is the OS's decision.
  • C. Correct. It saves state, runs the handler and returns.
Practice this topic Back to topic

More OS & Hardware questions

  1. What is the role of an interrupt vector table?
  2. What should you keep in mind when temporarily disabling (masking) interrupts during a critical section?
  3. Why is interrupt handling split into a short part done immediately and the remainder done later in a normal context?
  4. What is the role of a page table?
  5. When does a page fault occur?