- OS - Home
- OS - Needs
- OS - Overview
- OS - History
- OS - Components
- OS - Structure
- OS - Architecture
- OS - Services
- OS - Properties
- Process Management
- Operating System Processes
- Process Control Block
- Operations on Processes
- Inter Process Communication
- Context Switching
- Multi-threading
- Scheduling Algorithms
- Process Scheduling
- Preemptive and Non-Preemptive Scheduling
- Scheduling Algorithms Overview
- FCFS Scheduling Algorithm
- SJF Scheduling Algorithm
- Round Robin Scheduling Algorithm
- HRRN Scheduling Algorithm
- Priority Scheduling Algorithm
- Multilevel Queue Scheduling
- Lottery Scheduling Algorithm
- Turn Around Time & Waiting Time
- Burst Time in SJF Scheduling
- Process Synchronization
- Process Synchronization
- Critical Section Problem
- Critical Section Synchronization
- Mutual Exclusion Synchronization
- Semaphores
- Counting Semaphores
- Mutex
- Turn Variable
- Bounded Buffer Problem
- Reader Writer Locks
- Test and Set Lock
- Peterson's Solution
- Monitors
- Sleep and Wake
- Race Condition
- OS Deadlock
- Introduction to Deadlock
- Conditions for Deadlock
- Deadlock Handling
- Deadlock Prevention
- Deadlock Avoidance (Banker's Algorithm)
- Deadlock Detection and Recovery
- Deadlock Ignorance
- Memory Management
- Memory Management
- Contiguous Memory Allocation
- Non-Contiguous Memory Allocation
- First Fit Algorithm
- Next Fit Algorithm
- Best Fit Algorithm
- Worst Fit Algorithm
- Fragmentation
- Virtual Memory
- Segmentation
- Buddy System
- Slab Allocation
- Overlays
- Paging and Page Replacement
- Paging
- Demand Paging
- Page Table
- Page Replacement Algorithms
- Optimal Page Replacement Algorithm
- Belady's Anomaly
- Thrashing
- Storage and File Management
- File Systems
- File Attributes
- Structures of Directory
- Linked Index Allocation
- Indexed Allocation
- Disk Scheduling Algorithms
- FCFS Disk Scheduling
- SSTF Disk Scheduling
- SCAN Disk Scheduling
- LOOK Disk Scheduling
- I/O Systems
- I/O Hardware
- I/O Software
- OS Types
- OS - Types
- OS - Batch Processing
- OS - Multiprocessing
- OS - Hybrid
- OS - Monolithic
- OS - Zephyr
- OS - Nix
- OS - Linux
- OS - Blackberry
- OS - Garuda
- OS - Tails
- OS - Clustered
- OS - Haiku
- OS - AIX
- OS - Solus
- OS - Tizen
- OS - Bharat
- OS - Fire
- OS - Bliss
- OS - VxWorks
- OS - Embedded
- OS - Single User
- Miscellaneous Topics
- OS - Security
- OS Questions Answers
- OS - Questions Answers
- OS Useful Resources
- OS - Quick Guide
- OS - Useful Resources
- OS - Discussion
Operating Systems - Process Control Block
Process Control Block (PCB) is a data structure that contains information of the process related to it. The process control block is also known as a process descriptor or a task control block. The PCBs of the different processes are stored in a process table in the kernel of the operating system.
When a new process is created, the operating system initializes a process control block for it that stores the values of the parameters associated with the process as well as tracks the process state (i.e. new, ready, running, waiting or terminated).
PCBs are very important for process management for almost all process related activities. They are accessed and/or updated by many utility programs, like schedulers and resource managers. As PCBs track process state information, they play a vital role in context switching.
Structure of the Process Control Block
The process control stores many data items that are needed for efficient process management. Some of these data items are explained with the help of the given diagram −
The following are the data items −
- Process Number or ID − This shows the identification number of the particular process.
- Process State − This specifies the process state i.e. new, ready, running, waiting or terminated.
- Program Counter − This contains the address of the next instruction that needs to be executed in the process.
- Registers − This specifies the registers that are used by the process. They include accumulators, index registers, stack pointers, general purpose registers etc.
- List of Open Files − These are the different files that are associated with the process.
- CPU Scheduling Information − The process priority, pointers to scheduling queues etc. is the CPU scheduling information that is contained in the PCB. This may also include any other scheduling parameters.
- Memory Management Information − The memory management information includes the page tables or the segment tables depending on the memory system used. It also contains the value of the base registers, limit registers etc.
- I/O Status Information − This information includes the list of I/O devices used by the process, the list of files etc.
- Accounting Information − The time limits, account numbers, amount of CPU used, process numbers etc. are all a part of the PCB accounting information.
- Location of The Process Control Block − The process control block is kept in a memory area that is protected from the normal user access. This is done because it contains important process information. Some of the operating systems place the PCB at the beginning of the kernel stack for the process as it is a safe location.
Process Management Tasks That Utilize PCB
Process Control Blocks play an important role to perform various process management activities since they store the vital information related to the processes. Some of the major operations in which the details stored in PCBs are accessed frequently are enlisted as follows −
Context Switching
During context switching, the process state of the executing process is saved in the CPU register and a copy of it is stored in the corresponding PCB. The state of process which is selected for execution next is fetched from its PCB so that it can execute.
Process Scheduling
The operating system uses the contents of PCB such as process priority, process state, and resources utilized to schedule the processes from the ready queue. By assessing the priority and other related information, the scheduler determines the sequence of process execution.
Multitasking
The operating system can multitask and run various processes simultaneously with the help of information stored in PCBs like resource allocation, process scheduling, and process synchronization.
Resources Sharing
The information stored in the PCB includes the resources allocated to a process, like open files, shared variables, common tables and memory space. When a new process requests resources, the OS searches the allocated processes in the PCBs, checks whether they are shareable or not and allocates the resources accordingly. Thus PCBs play an important role in resource sharing.