Process in Operating System
Last Updated : 16 Sep, 2025
A process is a program in execution. For example, when we write a program in C or C++ and
compile it, the compiler creates binary code. The original code and binary code are both
programs. When we actually run the binary code, it becomes a process.
A process is an 'active' entity instead of a program, which is considered a 'passive' entity.
A single program can create many processes when run multiple times; for example,
when we open a .exe or binary file multiple times, multiple instances begin (multiple
processes are created). .
How Does a Process Look Like in Memory?
A process in memory is divided into several distinct sections, each serving a different purpose.
Here's how a process typically looks in memory.
Process structure
Text Section: A text or code segment contains executable instructions. It is typically a
read only section
Stack: The stack contains temporary data, such as function parameters, returns
addresses, and local variables.
Data Section: Contains the global variable.
Heap Section: Dynamically memory allocated to process during its run time.
Attributes of a Process
A process has several important attributes that help the operating system manage and control
it. These attributes are stored in a structure called the Process Control Block (PCB) (sometimes
called a task control block). The PCB keeps all the key information about the process, including:
1. Process ID (PID): A unique number assigned to each process so the operating system can
identify it.
2. Process State: This shows the current status of the process, like whether it is running,
waiting, or ready to execute.
3. Priority and other CPU Scheduling Information: Data that helps the operating system
decide which process should run next, like priority levels and pointers to scheduling
queues.
4. I/O Information: Information about input/output devices the process is using.
5. File Descriptors: Information about open files and network connections.
6. Accounting Information: Tracks how long the process has run, the amount of CPU time
used, and other resource usage data.
7. Memory Management Information: Details about the memory space allocated to the
process, including where it is loaded in memory and the structure of its memory layout
(stack, heap, etc.).
These attributes in the PCB help the operating system control, schedule, and manage each
process effectively.
States of a Process in Operating Systems
Last Updated : 02 Dec, 2025
A process in an operating system passes through multiple states as it begins execution, waits for
resources, gets scheduled, runs, and eventually finishes. When a program is launched and
becomes a process, it transitions through several well-defined stages based on its activity and
resource availability. These stages collectively describe the complete lifecycle of a process.
Common types of process state models include:
Two-State Model
Five-State Model
Seven-State Model
Two-State Model
The Two-State Model is the simplest representation of how a process behaves during its
lifetime. It divides the process lifecycle into only two possible conditions. A process is either
actively using the CPU to execute instructions or waiting until it gets a chance to run. This model
helps illustrate the basic interaction between a process and the CPU.
The two states are
Running: The process is currently using the CPU to execute its tasks.
Not Running: The process is not using the CPU. It may be waiting for input, waiting for
resources, or simply paused.
When a new process is created, it starts in the not running state. Initially, this process is kept in
a program called the dispatcher. here’s what happens step by step:
1. Not Running State: A newly created process starts here since it is not yet using the CPU.
2. Dispatcher Role: The dispatcher checks if the CPU is free for a new process.
3. Moving to Running State: If the CPU is available, the dispatcher loads the process onto
it, shifting it to the running state.
4. CPU Scheduler Role: The scheduler selects which process should run next based on the
OS’s scheduling policy.
The Five-State Model
The five-state process lifecycle expands the basic two-state idea by separating processes that
are simply waiting for CPU time from those that cannot run because they are waiting for an
external event. This makes the model more accurate for real operating systems, where
processes may pause for input, data, or device responses before continuing.
Five-State Model
The five states are:
New: The process has just been created. It hasn’t started running yet, but its PCB
(Process Control Block) is prepared.
Ready: The process is loaded into memory and prepared to run as soon as the CPU
becomes free.
Running: The CPU is currently executing this process. With a single CPU system, only one
process can be in this state at a time.
Blocked/Waiting: The process cannot continue execution because it is waiting for an
event like I/O completion or data input.
Exit/Terminate: The process has completed its execution or has been stopped, and the
operating system removes it from memory.
The Seven-State Model
A process moves through different states as it is created, prepared for execution, runs on the
CPU, waits for resources, or completes. These states help the operating system manage how
processes use memory, CPU, and I/O devices.
Seven State
The main process states are:
New: The process is in the creation phase. The program exists in secondary memory, and
the OS prepares its PCB before loading it into main memory.
Ready: The process has been loaded into main memory and is prepared to run. It is
waiting in the ready queue until the CPU becomes available.
Running: The CPU is currently executing the instructions of the process. Only one
process can be in this state at a time on a single-processor system.
Blocked/Waiting: The process cannot continue because it is waiting for an event such as
I/O completion, user input, or access to a locked resource. Once the event is complete, it
moves back to the ready state.
Terminated: The process has completed its execution or has been stopped. The OS
deletes its PCB and frees all resources allocated to it.
Suspend Ready: A ready process that has been swapped out of main memory and
placed in secondary storage due to memory shortage. When brought back to main
memory, it returns to the ready state.
CPU-Bound / I/O-Bound: A CPU-bound process spends most of its time performing
computations, while an I/O-bound process spends more time waiting for input/output
operations.
Movement of a Process From One State to Another
A process transitions between different states depending on its progress and the availability of
system resources. These movements help the operating system manage tasks efficiently.
New → Ready:
A process is created, resources are allocated, and it is loaded into main memory.
Ready → Running:
The scheduler selects a ready process and assigns the CPU to it.
Running → Blocked (Waiting):
The process must wait for an event or resource (e.g., I/O, user input, system call).
Blocked → Ready:
The event completes or the needed resource becomes available, so the process is ready
to run again.
Running → Ready:
The OS preempts the running process—often because a higher-priority process becomes
ready.
Running → Terminated:
The process completes its execution or is forcefully stopped.
Blocked → Terminated:
The process waiting for an event is aborted or killed by the OS or another process.
(General Rule):
A process may move between ready, running, and blocked many times,
but new and terminated happen only once in its lifetime.
Types of Schedulers
Long-Term Scheduler:
The long-term scheduler decides which new processes should enter the ready state and
controls the degree of multiprogramming.
Short-Term Scheduler:
The Short-term scheduler selects the next process from the ready queue to run on the
CPU and works very frequently.
Medium-Term Scheduler:
The medium-term scheduler handles swapping by suspending processes and moving
them between main memory and secondary storage.
Multiprogramming
We have many processes ready to run. There are two types of multiprogramming:
Preemption: Process is forcefully removed from CPU. Pre-emption is also called time
sharing or multitasking.
Non-Preemption: Processes are not removed until they complete the execution. Once
control is given to the CPU for a process execution, till the CPU releases the control by
itself, control cannot be taken back forcibly from the CPU.
The number of processes that can reside in the ready state at maximum decides the degree of
multiprogramming, e.g., if the degree of programming = 100, this means 100 processes can
reside in the ready state at maximum.
Operation on The Process
Creation: A process is created and placed in the ready queue (main memory), where it
waits to be executed.
Scheduling: The operating system selects one process from the ready queue to run next.
This selection step is called scheduling.
Execution: The CPU starts running the chosen process. If the process needs to wait for
an event or resource, it becomes blocked, and the CPU switches to another process.
Termination: Once the process completes its task, the OS terminates it and clears its
context.
Blocking: When a process waits for an event or resource (like I/O), it enters the blocked
state and cannot continue until that event is completed.
Context Switching: When the OS switches from one process to another, it saves the
current process’s context and loads the next one. This switching is called context
switching.
Inter-Process Communication (IPC): Processes often need to exchange data or
coordinate. The OS supports IPC using mechanisms like shared memory, message
passing, and synchronization tools.
These states—new, ready, running, waiting, and terminated—represent different stages in a
process's life cycle. By transitioning through these states, the operating system ensures that
processes are executed smoothly, resources are allocated effectively, and the overall
performance of the computer is optimized.
Process Table and Process Control Block (PCB)
Last Updated : 19 Sep, 2025
A Process Control Block (PCB) is a data structure used by the operating system to keep track of
process information and manage execution.
Each process is given a unique Process ID (PID) for identification.
The PCB stores details such as process state, program counter, stack pointer, open files,
and scheduling info.
During a state transition, the OS updates the PCB with the latest execution data.
It also includes register values, CPU quantum, and process priority.
The Process Table is an array of PCBs that maintains information for all active processes.
Structure of the Process Control Block
A Process Control Block (PCB) is a data structure used by the operating system to manage
information about a process. The process control keeps track of many important pieces of
information needed to manage processes efficiently. The diagram helps explain some of these
key data items.
Process Control Block
Pointer: It is a stack pointer that is required to be saved when the process is switched
from one state to another to retain the current position of the process.
Process state: It stores the respective state of the process.
Process number: Every process is assigned a unique id known as process ID or PID which
stores the process identifier.
Program counter: Program Counter stores the counter, which contains the address of
the next instruction that is to be executed for the process.
Register: Registers in the PCB, it is a data structure. When a processes is running and it's
time slice expires, the current value of process specific registers would be stored in the
PCB and the process would be swapped out. When the process is scheduled to be run,
the register values is read from the PCB and written to the CPU registers. This is the main
purpose of the registers in the PCB.
Memory limits: This field contains the information about memory management
system used by the operating system. This may include page tables, segment tables, etc.
List of Open files: This information includes the list of files opened for a process.
The Process Control Block (PCB) is stored in a special part of memory that normal users can't
access. This is because it holds important information about the process. Some operating
systems place the PCB at the start of the kernel stack for the process, as this is a safe and secure
spot.
Process Table
A process table is a data structure maintained by the operating system to keep track of all active
processes. It contains an entry for the Process Control Block (PCB) of each process, which stores
essential information like process ID, state, program counter, CPU registers, memory usage and
resource allocations.
Please note that the process table is not limited to only ID and reference to PCB, but in many OS
designs, its main role is to map a PID to its corresponding PCB. Some implementations may
store a few extra quick-access fields (like state, parent PID, or scheduling info) directly in the
process table for efficiency, but the bulk of process information is always in the PCB.
Roles of Process Table & Process Control Block
Help in Scheduling : Contains priority levels, CPU burst times and arrival times. Assists
the CPU scheduler in selecting the best process to run next.
Facilitate Context Switching : Stores CPU registers, stack pointers and other context-
related data.
Interrupt Handling: The PCB also contains information about the interrupts that a
process may have generated and how they were handled by the operating system.
Enable Inter-Process Communication (IPC) : PCB Includes pointers or flags related to
shared memory, pipes or message queues.
Support Resource Allocation : Tracks allocated resources (memory, files, I/O devices) per
process.
Essential for Process Synchronization and Deadlock Handling : Maintains info like locks
held/requested. Helps the OS detect and handle deadlocks or race conditions.
Security and Access Control : Contains user ID, group ID, permission levels, etc. Enforces
process-level access controls and restrictions.
Debugging and Monitoring : Process Table is used by monitoring tools (like top, ps) to
display process info. Helps in performance tuning and debugging applications.
Virtual Memory Management: The PCB may contain information about a process virtual
memory management, such as page tables and page fault handling.
Real-Time Systems: Real-time operating systems may require additional information in
the PCB, such as deadlines and priorities, to ensure that time-critical processes are
executed in a timely manner.