Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
A context switch occurs when the use of the processor is switched from one process to another process. When a context switch occurs, the system saves the context of the current running process and restores the context of the next process selected to use the processor. The PCB of the preempted process is updated. The process state field is changed from the running to the appropriate state (runnable, blocked, zombied, etc.). The contents of the processor’s registers, state of the stack, user and process identification and privileges, and scheduling and accounting information are saved and updated.
The system must keep track of the status of the process’s I/O and other resources, and any memory management data structures. The preempted process is placed in the appropriate queue.