Practice mode Operating Systems

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

Explanation

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.