Explain how an operating system can temporarily pass control of the CPU over to user code without risking an indefinite loss of control. Discuss the roles of timer interrupts, privileged mode operation, and memory protection and explain why all of these hardware mechanisms are essential in order to accomplish this task. Summarize by outlining the sequence of operations
that are performed by the operating system prior to handing over control of the CPU to user code and list several distinct ways in which control might return to the operating system.