operating-systemschedulingcontext-switchprocess-control

Storing and retrieving process control block


When a process is in execution, the contents of the PCB (which is in kernel memory space?) are loaded onto the CPU registers, and status registers, kernel stack pointers, user stack pointers, etc.

When there is a context switch to another process, the current "context" is stored back in the PCB and a switch is made to the new PCB.

Now when the kernel wants to bring back this PCB back into "context", how does it find this PCB, which is in the memory now? What information helps the kernel in finding the PCB which is in memory?


Solution

  • It's the job of schedular to look for the processor availability, then only context switch happens. As soon as core is available the Program Counter Value of stored PCBs in kernal is taken and given to CPU registers. I would like to tell the PCBs are stored in stack fashion by the kernal.