Saving the value of registers during context switch

954 Views Asked by At

During Context Switching, the kernel saves the state of current process (process1) and restores the state of the other process (process2) into CPU (loads the various registers with the previous values for process2).

Which memory area the kernel saves the state of process1 when it is swapped out? Is it in the stack area of process1 or is it in some place within kernel itself? Thanks in advance.

1

There are 1 best solutions below

0
On

This will be saved in the Process Control Block (PCB) of the associated process (process1) itself; not in stack. PCB has many sections like text(code), data(for global variables), stack pointer, heap pointer, register values, process state etc.