What is Process Control Block (PCB)?

Process Control Block

Every processA executable entity that is composed of one or more threads has certain information associated with itself. Because the operating system has countless requests for the execution of various programs and routines, each request for executing entity is kept track of via a unique Process ID.

An example of Operating System multitasking to execute different processes

Note: Don't confuse a process with a thread. A process is always composed of one or more threads.

What is kept track of?

Each Process ID maps onto a container-like memory block that contains the relevant information associated with the corresponding Process ID. This representation of the information is referred to as Process Control Block (PCB).

Some of the information stored in a PCB is shown in the diagram above and elaborated below:

  • Pointer It is a reference to the existing stateProgress of the process on the caller stack. of the respective process on the stack.

  • Process State: The state of the process, which can vary from running, waiting, terminated, or blocked.

  • Process ID: The unique identifier of the process (and the Process Control Block).

  • Program Counter: It is a counter that refers to the memory address that stores the next instruction to be executed.

  • Registers: These are dedicated small and temporary data storage locations that can store process execution-relevant information. Memory Data Register and Memory Address Register are two examples of registers.

  • Memory Limits: This refers back to the page tables or memory references that are dedicated to the respective process.

  • List of Open Files: Files are the operating system's memory storage zones in the secondary storage devices. The list of relevant files flagged as accessible for the process is stored accordingly.

Simplistic implementation

The implementation of the PCB can be abstracted in the form of a struct definition, as shown below:

#include <iostream>
using namespace std;
struct processControlBlock{
void * stack; //stack pointer
pid_t pid; // process id
struct files_struct *files; //pointer to files open
// you can add more variables
// to store process related information
};
int main() {
processControlBlock instance_process;
// your code goes here
return 0;
}

The code above is an example of an abstracted implementation of how a Process Control Block (PCB) can be implemented as a struct with member variables storing the process-related information.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved