Process management is the part of an operating system that creates, schedules, runs, pauses, resumes, and terminates processes. A computer usually has many programs open at the same time, but the CPU can execute only a limited number of tasks at once. The operating system makes this sharing possible.
The OS keeps track of every running process, gives it CPU time, allocates memory and I/O resources, handles communication between processes, and cleans up resources when the process finishes.
A program and a process are related, but they are not the same. A program is passive code stored on disk. A process is an active instance of that program while it is running.
| Feature | Program | Process |
|---|---|---|
| Meaning | A set of instructions stored in a file | A program currently in execution |
| Nature | Passive | Active |
| Storage | Secondary storage such as HDD or SSD | Main memory while running |
| Resources | Does not own CPU, registers, or open files | Has allocated resources such as memory, files, and CPU state |
| Example | chrome.exe stored on disk | Each opened Chrome instance or tab-related process |
When a program becomes a process, the OS loads it into memory and organizes its memory into different sections. Each section has a specific purpose.
High Memory
+------------------+
| Stack | Function calls and local variables
+------------------+
| Heap | Dynamic memory allocation
+------------------+
| Data | Global and static variables
+------------------+
| Text / Code | Program instructions
+------------------+
Low Memory
The Process Control Block, or PCB, is a kernel data structure that stores all important information about a process. The OS uses the PCB to pause a process, resume it later, schedule it, identify it, and manage its resources.
| PCB Field | Purpose |
|---|---|
| Process ID (PID) | Unique number used to identify the process |
| Process state | Current state such as ready, running, waiting, or terminated |
| Program counter | Address of the next instruction to execute |
| CPU registers | Saved register values needed to resume execution |
| CPU scheduling information | Priority, scheduling queue pointers, and time-related details |
| Memory management information | Page tables, segment tables, base registers, or limit registers |
| I/O status information | Open files, allocated devices, and pending I/O requests |
| Accounting information | CPU time used, user ID, process owner, and resource usage |
A process moves through different states during its lifetime. These states help the OS decide which process should run, which process is waiting, and which process is finished.
New --admitted--> Ready --dispatch--> Running --exit--> Terminated
^ |
| |
I/O done | I/O request
| v
Waiting <--- blocked
Running --preempted--> Ready
The operating system organizes processes into queues. A queue is a waiting line of processes that need the same kind of service.
| Queue | Contains | Purpose |
|---|---|---|
| Job queue | All processes in the system | Tracks processes that exist or are waiting to enter memory |
| Ready queue | Processes ready to execute | CPU scheduler chooses from this queue |
| Device queue | Processes waiting for an I/O device | Each device can have its own waiting queue |
A scheduler decides which process should move from one stage to another. Different schedulers work at different levels of the operating system.
| Scheduler | Role | Frequency |
|---|---|---|
| Long-term scheduler | Selects jobs from disk and loads them into memory | Runs less frequently |
| Short-term scheduler | Selects the next ready process to run on the CPU | Runs very frequently |
| Medium-term scheduler | Temporarily swaps processes out of memory and brings them back later | Runs when memory pressure exists |
A context switch happens when the CPU stops running one process and starts running another. The OS saves the current process state into its PCB and loads the saved state of the next process.
Context switching is necessary for multitasking, but it is also overhead because the CPU spends time switching instead of executing user instructions. A good OS tries to balance responsiveness with switching cost.
A process can create another process. The creating process is called the parent process, and the new process is called the child process. Operating systems use this parent-child relationship to organize and control running tasks.
In Unix and Linux systems, process creation commonly uses fork() and exec().
Parent process
|
| fork()
v
Parent process continues Child process starts
| |
| wait() | exec()
| v
| New program runs
| |
| exit()
v
Parent receives child exit status
A process terminates when it finishes normally, encounters an error, is killed by another process, or is stopped by the operating system. After termination, the OS releases the process resources such as memory, open files, and I/O devices.
Two important special cases in process termination are zombie processes and orphan processes. They are common interview and exam topics.
| Type | Meaning | Why It Happens |
|---|---|---|
| Zombie process | A child process has finished, but its process table entry still exists | The parent has not collected its exit status using wait() |
| Orphan process | A child process is still running after its parent has terminated | The parent exits before the child finishes |
Processes often need to exchange data or coordinate work. Since separate processes usually have separate memory spaces, the OS provides Interprocess Communication, or IPC, mechanisms.
| IPC Method | How It Works | Common Use |
|---|---|---|
| Pipes | One process writes data and another reads it | Command chaining in shells |
| Message queues | Processes exchange structured messages through the OS | Producer-consumer communication |
| Shared memory | Multiple processes access the same memory region | Fast data sharing |
| Signals | Small notifications sent to a process | Stop, terminate, or reload a process |
| Sockets | Processes communicate over a network or local machine | Client-server applications |
Different operating systems provide tools to view and manage processes. These commands help users and administrators inspect CPU usage, memory usage, process IDs, and parent-child relationships.
| System | Command or Tool | Purpose |
|---|---|---|
| Linux / Unix | ps | Shows current processes |
| Linux / Unix | top or htop | Shows live process CPU and memory usage |
| Linux / Unix | kill | Sends a signal to a process |
| Windows | Task Manager | Graphical tool for viewing and ending processes |
| Windows | tasklist and taskkill | Command-line tools for listing and terminating processes |
| Concept | Remember This |
|---|---|
| Process | A program in execution |
| PCB | Stores all information needed to manage and resume a process |
| Ready state | Process is waiting for CPU time |
| Waiting state | Process is waiting for I/O or another event |
| Context switch | Saves one process state and loads another process state |
| IPC | Allows processes to communicate and synchronize |
Process management is the OS function responsible for creating, scheduling, executing, blocking, resuming, and terminating processes.
A program is passive code stored on disk. A process is an active instance of a program running in memory with allocated resources.
The PCB stores the process state, registers, program counter, memory details, scheduling information, and I/O status needed by the OS to manage the process.
The OS saves the current process state in its PCB, chooses another process, loads that process state, and resumes execution.
A zombie process is a terminated child process whose exit status has not yet been collected by its parent process.
Explore 500+ free tutorials across 20+ languages and frameworks.