What steps are taken when the os shifts from one-thread execution to another?


#1

Can someone please explain me in detail


#2

In a switch, the state of process currently executing must be saved somehow, so that when it is rescheduled, this state can be restored.

The process state includes all the registers that the process may be using, especially the program counter, plus any other operating system specific data that may be necessary. This is usually stored in a data structure called a process control block (PCB) or switchframe.

A handle to the PCB is added to a queue of processes that are ready to run, often called the ready queue.