I m new to operating system concepts. I have read that a PCB contains the information about the Registers .. By that does it mean “it contains all the registers’ contents at that particular instance of time” or ” only the registers which belong to a particular process ” ? If its the second case, please tell me how does a os keep track of which registers belong to which process ?
Thanks
Registers are specific to architecture, this is a description of registers in x86 architecture
http://en.wikipedia.org/wiki/X86_architecture#x86_registers.
The CPU architecture specification defines each register and it’s purpose. It is these guidelines, that OS developers should follow while designing and developing the OS. In terms of a process the important registers are SP(stack pointer), BP(base pointer) and IP(instruction pointer). Control registers(cr0-cr8) are also used by the process for computation. There are registers which is used by operating system like IDTR, which is used by OS to point to the Interrupt descriptor table. IDT is used for calling the right function when a interrupt happens.
When you talk about registers in the PCB, then it is a data structure. When a processes is running and it’s time slice expires, the current value of process specific registers would be stored in the PCB and the process would be swapped out. When the process is scheduled to be run, the register values is read from the PCB and written to the CPU registers. This is the main purpose of the registers in the PCB.