Process control block (PCB) is a data structure used by a computer operating system to store all the information about a process.
The operating system used a data structure named Process Control Block(PCB) to store the information about a particular process, and this information is required by the CPU while executing the process. Each process is identified by its process block, the process control block is also known as a task control block.
When a process is created (initialized or installed), the operating system creates a corresponding process control block.
Information in a process control block is updated during the transition of process states.
When the process terminates, its PCB is returned to the pool from which new PCBs are drawn.
Each process has a single PCB.
Components of PCB are
Basically stores the respective stage of the program whether the process is in a new, ready, running, or terminated state, etc. So, to understand this process state clearly, we have to understand the process life cycle first.
In the process life cycle, we discuss how a process goes through various process states before its termination.
New: Process has just been created in this state. It is the initial state in the process life cycle.
Ready: In this process is ready and is waiting to be assigned to the processor so it can run.
Ready suspended: Process goes through this state when we have a lack of main memory and because of this, the process is going into a ready suspended process state(which is in secondary memory) and when space is created in the main memory it came back to the ready process state and then gets executed.
Running: After the ready process state process is dispatched into the running state and in this running state,
we have three cases
Case 1: When the process is completed without any interruption and directly goes into a termination state.
Case 2: When interrupt takes place – Interrupts are signals sent to CPU by external devices. They tell the CPU to stop its current activity. The controls then pass to a special piece of code called an interrupt handler. The interrupt handler will process the interrupt and resume the interrupted program.
Case3: I/O request When a process request for I/O for its completion then the process goes into a blocked process state until the I/O request is completed and when the request is completed the process came back to ready state and from there it goes to running and then to the terminated state after its execution.When a process request for I/O for its completion then the process goes into a blocked process state until the I/O request is completed and when the request is completed the process came back to ready state and from there it goes to running and then to the terminated state after its execution.
:Process comes to this state when it is waiting for some event to occur. For ex- I/O request.
Blocked Suspended:It is similar to a ready suspended state. Processes in a blocked suspended state are in secondary memory, a process in the blocked state is in main memory but due to lack of memory, they are forced to move in the blocked suspended state.
Terminated: The process is removed from the main memory and its process control block is deleted.
Process Counter is a special kind of register that is used by the processor to hold the address of the next instruction to be executed.
A unique identifier for the process.
CPU register tells us about the different kinds of registers that are being used by a particular process. They may include accumulators, index registers, stack pointer, and general-purpose registers.
It contains information about the memory management system used by the operating system. This may include page tables, segment tables, etc.
List of open files
It represents the files associated with the process. So the CPU should maintain a list of files that are being opened by a process to make sure that no other process can open the files at the same time.
Miscellaneous Accounting and Status data
This includes information about the amount of CPU used, time constraints, process number, etc.
This was very small article about PCB and its component. If you like the article please share and subscribe.