Process Table and Process Control Block (PCB)

1. Process Control Block (PCB)
  • The Process Control Block (PCB) is a data structure in the operating system that contains key information about a process. It acts as a repository for all the data needed to manage a specific process.

  • It's also known as a task control block.

  • The operating system creates a PCB for each new process.

1.1 Information Stored in a PCB:
  • Process State: Current state of the process (e.g., New, Ready, Running, Waiting, Halted).

  • Process ID (PID): A unique identifier for the process.

  • Program Counter (PC): Points to the address of the next instruction to be executed for this process.

  • CPU Registers: Values of all CPU registers for the process, saved when the process is interrupted.

  • CPU Scheduling Information: Priority of the process, pointers to scheduling queues.

  • Memory Management Information: Base and limit registers, page tables, or segment tables related to the process's memory space.

  • Account Information: CPU usage, real time used, time limits, process number.

  • I/O Status Information: List of I/O devices allocated to the process, list of open files.

2. Process Table
  • The Process Table is a system-wide table maintained by the operating system, which contains an entry for each active process in the system.

  • Each entry in the Process Table is essentially a pointer to the Process Control Block (PCB) of a specific process.

  • Think of it as an array or a list where each element points to a PCB.

2.1 Relationship between Process Table and PCB:
  • The Process Table provides a quick way for the operating system to access the PCBs of all active processes.

  • When the CPU switches from one process to another (context switch), the operating system uses the Process Table to locate the PCB of the new process it needs to run, load its context (data from the PCB) into the CPU registers, and then resume execution.

  • This structure allows the OS to effectively manage multiple processes concurrently.