I am asked to describe the steps involved in a context switch (1) between two different processes and (2) between two different threads in the same process.
1.Save the context of the process that is currently running on the CPU. Update the process control block and other important fields.
2.Move the process control block of the above process into the relevant queue such as the ready queue, I/O queue etc.
3.Select a new process for execution.
4.Update the process control block of the selected process. This includes updating the process state to running.
5.Update the memory management data structures as required.
6.Restore the context of the process that was previously running when it is loaded again on the processor. This is done by loading the previous values of the process control block and registers.