2
votes

According to this question: Storing and retrieving process control block

PCB contains a lot of information and it is managed by the kernel (to avoid user access).

But I have question about PC and CPU registers. Is Kernel save these values every time an instruction is executed or only in context switching process?

Are PCBs linked list?

1

1 Answers

3
votes

Actually, the value of CPU registers are modified as per the running sequence of instructions.

Say,the Instruction Pointer points to next instruction to be executed, the Stack Pointer,if active,would store the address of the last program request in a stack. And so on. These all are basically CPU registers!

PCB has one of the part Processor state data,which are those pieces of information that define the status of a process when it's suspended, allowing the OS to restart it later and still execute correctly. This always includes the content of the CPU general-purpose registers, the CPU process status word, stack and frame pointers etc. During context switch, the running process is stopped and another process is given a chance to run. The kernel must stop the execution of the running process, copy out the values in hardware registers to its PCB, and update the hardware registers with the values from the PCB of the new process. // (Taken from Wikipedia)

Does Kernel save these values every time an instruction is executed or only in context switching process?

So,you might have got your question solved. The kernel only bothers saving values of hardware(CPU) registers in the case of context switching,not normally. Else,it leaves the burden on process itself to maintain the registers!

Also, the last question's answer is---The implementation of PCB is 'generally' done as a doubly linked list data structure!