Process control block explained

A process control block (PCB), also sometimes called a process descriptor, is a data structure used by a computer operating system to store all the information about a process.

When a process is created (initialized or installed), the operating system creates a corresponding process control block, which specifies and tracks the process state (i.e. new, ready, running, waiting or terminated). Since it is used to track process information, the PCB plays a key role in context switching.[1]

An operating system kernel stores PCBs in a process table.[2]

The current working directory of a process is one of the properties that the kernel stores in the process's PCB.[3]

Role

The role of the PCBs is central in process management: they are accessed and/or modified by most utilities, particularly those involved with scheduling and resource management.

Structure

In multitasking operating systems, the PCB stores data needed for correct and efficient process management.[4] Though the details of these structures are system-dependent, common elements fall in three main categories:

Status tables exist for each relevant entity, like describing memory, I/O devices, files and processes.

Memory tables, for example, contain information about the allocation of main and secondary (virtual) memory for each process, authorization attributes for accessing memory areas shared among different processes, etc. I/O tables may have entries stating the availability of a device or its assignment to a process, the status of I/O operations, the location of memory buffers used for them, etc.

Process identification data include a unique identifier for the process (almost invariably an integer) and, in a multiuser-multitasking system, data such as the identifier of the parent process, user identifier, user group identifier, etc. The process id is particularly relevant since it is often used to cross-reference the tables defined above, e.g. showing which process is using which I/O devices, or memory areas.

Process state data define the status of a process when it is suspended, allowing the OS to restart it later. This always includes the content of general-purpose CPU registers, the CPU process status word, stack and frame pointers, etc. During context switch, the running process is stopped and another process runs. The kernel must stop the execution of the running process, copy out the values in hardware registers to its PCB, and update the hardware registers with the values from the PCB of the new process.

Process control information is used by the OS to manage the process itself. This includes:

Location

PCB must be kept in an area of memory protected from normal process access. In some operating systems the PCB is placed at the bottom of the process stack.[5]

See also

Notes and References

  1. Web site: Process Control Block | Baeldung on Computer Science . 25 June 2020 .
  2. Web site: Class 9: The Unix Filesystem . 2023-12-09 . www.usna.edu.
  3. Web site: CS 537 Notes: Directories . 2023-12-09 . pages.cs.wisc.edu.
  4. Book: Gagne, Abraham Silberschatz, Peter Baer Galvin, Greg. Operating system concepts. 2013. limited. Wiley. 9781118063330. 9th. Hoboken, N.J.. 107–108.
  5. Yong, Zhang, "Breaking through the Maximum Process Number", "Linux Journal", 1 January 2004, http://www.linuxjournal.com/article/4407.