Description
In computer science, a process is an instance of a program that is actively executing. While a program is a passive set of instructions stored on disk, a process is a dynamic execution of that program — with its own memory space, CPU state, registers, and system resources. Every time you launch an application on your operating system, you are starting a new process.
A process represents the fundamental unit of execution in modern operating systems, responsible for isolating running programs and managing their execution in a safe, concurrent environment.
How It Works
When a program is executed, the operating system performs several steps to create a process:
- Loads the program code into memory.
- Allocates memory space for variables, heap, and stack.
- Initializes CPU registers, including the program counter (PC) and stack pointer.
- Creates a process control block (PCB) — a data structure to track all details about the process.
- Assigns a unique Process ID (PID).
The operating system uses process scheduling to allocate CPU time to various processes, using strategies like round-robin, priority-based, or multilevel queue scheduling.
Main Components of a Process:
| Component | Description |
|---|---|
| Text segment | Contains the program code |
| Data segment | Contains global/static variables |
| Heap | Dynamically allocated memory during runtime |
| Stack | Stores function calls, parameters, local variables |
| Registers | Holds CPU state such as PC, SP, and general-purpose regs |
| Open files | Handles to resources like files or sockets |
Process Lifecycle
A process goes through a well-defined lifecycle:
- New – The process is being created.
- Ready – It is loaded into memory and waiting for CPU time.
- Running – Currently executing instructions on the CPU.
- Waiting – Blocked, waiting for I/O or another event.
- Terminated – Completed execution or was forcefully stopped.
Most modern systems use a process scheduler to manage transitions between these states based on fairness, priority, and system load.
Process vs Thread
While a process is a heavyweight execution unit with its own memory and resources, a thread is a lightweight execution unit that shares memory within the same process.
| Feature | Process | Thread |
|---|---|---|
| Memory Space | Separate | Shared with other threads |
| Overhead | Higher | Lower |
| Communication | Inter-process Communication (IPC) | Direct via shared memory |
| Isolation | Strong | Weak (shared resources) |
Example:
Running two different browser windows (Chrome and Firefox) involves separate processes, while opening two tabs in Chrome may create separate threads (or processes, depending on the architecture).
Use Cases
Processes are ubiquitous. Every time you:
- Open a web browser
- Launch a video player
- Run a script
- Start a background daemon or service
…you’re starting a new process. Some specialized use cases:
1. Multiprocessing Systems
Used in high-performance computing (HPC) and server environments. Each core can run a separate process for parallel computation.
2. Process Isolation in Operating Systems
Security and stability are enforced by isolating processes:
- If one crashes, others remain unaffected.
- Malware cannot easily access data from other processes.
3. Child Processes and Forking
Many systems use child processes to spawn sub-tasks. In Unix:
pid_t pid = fork();
Creates a child process identical to the parent.
4. Service and Daemon Processes
Background services like sshd, nginx, cron, etc., run as persistent processes.
5. Process Pools
Used in parallel task execution frameworks (e.g., Python’s multiprocessing.Pool) for scalable computation.
Programming Examples
🔹 Unix C – Forking a Child Process
#include
#include
int main() {
pid_t pid = fork();
if (pid == 0) {
printf("Child Process\n");
} else {
printf("Parent Process\n");
}
return 0;
}
🔹 Python – Multiprocessing
from multiprocessing import Process
def task():
print("Running in a separate process")
p = Process(target=task)
p.start()
p.join()
🔹 Bash – Running a Process in Background
sleep 30 &
Starts a background process.
Process Control and Commands
Unix/Linux Commands:
ps– list running processestop/htop– monitor CPU/memory usagekill PID– terminate processnice/renice– adjust process prioritypidof– get PID of a running program
Windows Commands:
tasklist– list all running processestaskkill /PID– terminate by PID- Task Manager (GUI)
Inter-Process Communication (IPC)
Processes are isolated by default, but they can communicate using IPC mechanisms:
- Pipes
- Message Queues
- Shared Memory
- Sockets
- Signals (Unix)
Each mechanism offers different trade-offs in speed, complexity, and safety.
Example (Python multiprocessing Pipe):
from multiprocessing import Pipe, Process
def child(conn):
conn.send("Hello from child!")
conn.close()
parent_conn, child_conn = Pipe()
p = Process(target=child, args=(child_conn,))
p.start()
print(parent_conn.recv())
p.join()
Process Scheduling
Operating systems use schedulers to manage process execution. Common algorithms include:
- First-Come First-Serve (FCFS)
- Shortest Job Next (SJN)
- Round Robin
- Priority Scheduling
- Multilevel Queue Scheduling
Schedulers determine which process runs next and how long it stays on the CPU.
Zombie and Orphan Processes
- Zombie: A process that has finished execution but still has an entry in the process table.
- Orphan: A child process whose parent has terminated.
These are handled by the system’s init process (PID 1) in Unix-like systems.
Process Security
Processes are fundamental to sandboxing and application-level security.
- User-level isolation: Processes are run with permissions of the user.
- Memory protection: Each process has its own virtual memory space.
- Syscalls: Controlled access to OS-level operations.
In secure environments, processes are also constrained using containers, AppArmor, or SELinux.
Real-World Analogy
A process is like a worker on an assembly line:
- The program is the blueprint.
- The process is the worker using the blueprint.
- Each process has its own workspace, tools, and materials (memory, registers, I/O).
- Multiple workers can perform the same task in parallel.
Related Terms
- Thread
- Multiprocessing
- Fork
- Daemon
- Scheduler
- Zombie Process
- Orphan Process
- Process Control Block (PCB)
- Virtual Memory
- Context Switch
- IPC
- Signal
- System Call









