More about PCB (Process Control Block)
In an operating system, each process has a Process Control Block (PCB) which serves a similar purpose to a student's identity card or ID card. Just as an ID card contains important information about a student, the PCB contains essential information about a process. Here's a simplified explanation:
- Student ID Card: Contains information like the student's name, ID number, class, and other relevant details.
- Process Control Block (PCB): Contains information like the process ID, process state, CPU registers, memory management information, accounting information, and I/O status.
The PCB helps the operating system manage and keep track of all the processes running on the system, ensuring that each process is correctly handled and allocated the necessary resources.
1. Process ID
In college, each student is given a unique registration number for identification. Similarly, in an operating system, each process is assigned a unique Process ID (PID) by the OS. This PID helps the operating system to identify and manage each process individually.
2. Program Counter
f there is a process P1 that has to execute 10 instructions and it has only executed 6 so far, but it needs to perform some input/output operation, the process will be temporarily paused. When P1 comes back to the CPU for further execution, it needs to know from where to continue.
For this purpose, we have the Program Counter (PC). The Program Counter stores the address of the next instruction that needs to be executed. When the process is paused, the current value of the Program Counter is saved in the Process Control Block (PCB). When the process resumes, the value is restored from the PCB, allowing the process to continue execution from where it left off.
3. Process State
Just like a human can be in different states such as sleeping, studying, running, eating, or talking, a process in a computer system can also be in various states. These states define what the process is currently doing. The common states of a process include:
- New: In this step, the process is about to be created but not yet created. It is the program that is present in secondary memory that will be picked up by the OS to create the process.
- Ready: The process is waiting to be assigned to the CPU.
- Running: The CPU is currently executing the process.
- Blocked/Waiting: The process is waiting for some event to occur (such as input/output operation completion).
- Suspended: The process is temporarily halted, often due to swapping.
- Terminated: The process has finished execution and is being removed from the system.
4. Priority
Imagine you're standing in line to get into a lounge. If a VIP person arrives, they are given priority and allowed in first. Similarly, in a computer system, some processes are given higher priority. These high-priority processes are often operating system (OS) processes, while lower-priority processes are typically user processes.
If a user process is currently executing and an OS process needs to be executed, the user process will be halted (paused). The OS process, being more critical, will take over the CPU. Once the OS process is completed, the user process will resume execution from where it was halted.
This priority system ensures that important system tasks are handled promptly, maintaining the overall efficiency and stability of the operating system.
5. Register
Imagine a user process is executing and the values in the CPU registers are 1,3,2. If an OS process needs to be executed, it will interrupt the user process, causing the values in the registers to change. To ensure that the user process can resume exactly where it left off, the current state of the registers needs to be saved.
For this purpose, the register section in the Process Control Block (PCB) is used. When the user process is halted, the current values of the CPU registers are saved in its PCB. Once the OS process is terminated, the values from the PCB are restored back to the registers. This allows the user process to continue execution from where it was paused, with the correct register values.
This process is known as context switching. It ensures that the state of the CPU (including register values) is preserved for each process, allowing multiple processes to share the CPU efficiently without losing their individual progress.
6. List of Open Files
While executing, a process may need to read, write, or open various files based on its instructions. To keep track of which files have been opened by a process, the operating system maintains a list of open files for each process. This list is also stored in the Process Control Block (PCB).
7. Input/Output information
The input/output (I/O) devices required for a process's execution are tracked and managed by the operating system. This information is stored in the I/O information section of the Process Control Block (PCB).

Well done
ReplyDelete