Process: Context Switching:
What is a Context Switching?:A Context Switch(also sometimes referred to as a Process switch or a task switch) is the switching off the CPU from one process to another.
A context is the contents of a CPU's registers and program counter at any point in time.
Context Switch Steps
If two processes A and B are in ready queue.
If CPU is executing process A and process B in wait state. <
If an interrupt occurs for process A, The operating system suspends the execution of the first process, and store the current information of process A in its PCB and context to the second process namely process B.
In doing So, program counter from PCB of process B is loaded and the execution can continue with the new process.
***The switching between two processes, process A and process B needs PCB to save the state.***