Why does an operating system program a hardware timer to interrupt the CPU periodically?
Correct answer D. To stop a user program from keeping the CPU forever, so the kernel regains control
If a program enters an infinite loop or never makes a system call, the kernel would otherwise never run again. A timer interrupt guarantees that control returns to the OS after a set interval, which is what lets preemptive schedulers enforce time slices. Setting the timer is a privileged instruction so user code cannot disable it.
Answer checked How we write and check questions
Discussion