Step 01

Concepts of a Process

Before scheduling or deadlocks make any sense, we must be crystal clear about what a process is. Start here — every term is explained before it is used.

What is a Process?

A program is a set of instructions written to perform a task. It is a passive entity stored on disk, such as an executable file or source code, waiting to be launched. A process is the program in execution. When you double-click an app, the operating system copies the program's instructions from disk into main memory (RAM), gives it a unique number called a PID (Process ID), reserves memory for it, and starts executing its instructions on the CPU.

Program — a passive file stored on disk containing instructions
Process — an active instance of that program, running in memory
PID — a unique number the OS uses to identify each process
Program Counter (PC) — register holding the address of the next instruction

Real-world analogy: The recipe and the cooking

A program is like a recipe written in a book — it just sits there. A process is the dish actually being cooked right now: it uses the kitchen (CPU), ingredients (memory), and has a current step (program counter). Two chefs can cook the same recipe at the same time — that is two processes from one program.
Comparison of a static program on disk with a running process in memory, including the program-to-process execution flow and multiple process instances.
A program is static code on disk; running it creates an active process in memory.
Experiment: One program, many processes

Click “Run this program” several times. Notice the program on the left never changes, while each click creates an independent process with its own PID.

Program (on disk — passive)

// calc.exe
int main() {
  print("Hello");
  return 0;
}

Processes (in memory — active)

No process yet. One program can be started many times — each start creates a brand new process with its own PID and its own memory.

Process memory layout showing stack, heap, data, and text/code segments in a running process.
A process is not one blob of memory — it is organized into code, data, heap and stack segments.
How memory is organized inside a process
SegmentPurposeKey characteristics
StackStores temporary runtime data like function parameters, return addresses, and local variables.Works in a LIFO (Last In, First Out) manner.
HeapUsed for dynamic memory allocation during runtime.Memory is allocated and freed manually (or via garbage collection in some languages).
Data SegmentStores global and static variables.Exists throughout the entire program execution.
Text SegmentContains the actual compiled program instructions.Read-only section, also includes program counter information.
Program vs Process vs Thread
PointProgramProcess
NaturePassive (static)Active (dynamic)
LocationStored on diskLoaded in main memory
LifetimeExists until deletedExists until it terminates
ResourcesNeeds noneNeeds CPU, memory, files, I/O
CountOne copy of the fileMany processes from one program
OS recordNoneHas a PCB in the OS
How the OS creates and ends processes

Quick quiz

1. Which statement is TRUE?

2. What do two threads of the same process NOT share?

Practice problem

You open the Chrome browser three times and each window opens two tabs handled by separate threads. How many processes and how many threads exist (counting only these)?