2

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?

Community
  • 1
  • 1
Mahmoud Emam
  • 1,499
  • 4
  • 20
  • 37

1 Answers1

3

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!

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
  • 1
    first thanks for your reply and and I have another question is process-table the form of doubly linked list for PCBs? – Mahmoud Emam Jul 05 '14 at 14:31
  • I think it is implemented using doubly linked list,but I'm not sure. You better frame a new question for that,you may get your response.maybe,i'll come up with something and will let you know! – Am_I_Helpful Jul 05 '14 at 19:15