Process Control Block in Operating System

In the last blog, we learned about Processes in Operating System and various states of a Process. If you are not familiar with Process in OS then you must ready that blog from here . In this blog, we will learn about Process Control Block in the Operating System. So, let's get started.

In an Operating System, we have a number of processes present in it. Each process has some information that is needed by the CPU for the execution of the process. So, we need some kind of data structure to store information about a particular process.

A Process Control Block or simple PCB is a data structure that is used to store the information of a process that might be needed to manage the scheduling of a particular process.

So, each process will be given a PCB which is a kind of identification card for a process. All the processes present in the system will have a PCB associated with it and all these PCBs are connected in a Linked List.

Attributes of a Process Control Block

There are various attributes of a PCB that helps the CPU to execute a particular process. These attributes are:

  • Process Id: A process id is a unique identity of a process. Each process is identified with the help of the process id.
  • Program Counter: The program counter, points to the next instruction that is to be executed by the CPU. It is used to find the next instruction that is to be executed.
  • Process State: A process can be in any state out of the possible states of a process. So, the CPU needs to know about the current state of a process, so that its execution can be done easily. You can learn more about process state from here .
  • Priority: There is a priority associated with each process. Based on that priority the CPU finds which process is to be executed first. Higher priority process will be executed first.
  • General-purpose Registers: During the execution of a process, it deals with a number of data that are being used and changed by the process. But in most of the cases, we have to stop the execution of a process to start another process and after some times, the previous process should be resumed once again. Since the previous process was dealing with some data and had changed the data so when the process resumes then it should use that data only. These data are stored in some kind of storage units called registers.
  • CPU Scheduling Information: It indicates the information about the process scheduling algorithms that are being used by the CPU for the process.
  • List of opened files: A process can deal with a number of files, 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 file at the same time.
  • List of I/O devices: A process may need a number of I/O devices to perform various tasks. So, a proper list should be maintained that shows which I/O device is being used by which process.

These are the attributes of a Process Control Block and these pieces of information are needed to have detailed info about the process and this, in turn, results in better execution of the process.

That's it for this blog. Hope you learned something new today.

Do share this blog with your friends to spread the knowledge. Visit our YouTube channel for more content. You can read more blogs from here .

Keep Learning :)

Team AfterAcademy!