OS & Hardware

What mechanism mainly lets the OS reclaim the CPU at regular intervals, even from programs that never give it up voluntarily, and switch to other processes?

  1. ACache misses
  2. BTimer interrupts
  3. CCopy-on-write
Show answer and explanation

Answer: B. Timer interrupts

The OS programs a timer to raise an interrupt after each time slice. When it fires, the CPU always enters the kernel's interrupt handler, so even if a program is stuck in an infinite loop, the OS regains control and can context-switch to another process. This is preemptive scheduling. Cache misses and copy-on-write do not return control to the OS.

  • A. Cache misses are handled in hardware and do not transfer control to the OS.
  • B. Correct. Periodic interrupts let the OS regain control.
  • C. Copy-on-write copies pages when they are written.
Practice this topic Back to topic

More OS & Hardware questions

  1. When reading a device status register via memory-mapped I/O as above, why is it declared volatile and the region configured as uncached?
  2. When is polling, in which the CPU repeatedly checks device status instead of using interrupts, advantageous?
  3. In a system where hardware does not keep caches coherent, what must software do before the CPU reads data a device wrote to main memory via DMA?
  4. What is the main role of an IOMMU?
  5. What is the role of a device driver?