In an Operating System (OS), the terms program and process are often used interchangeably, but they have distinct meanings. Understanding their differences is crucial in OS design, process management, and scheduling.
1. What is a Program?
A program is a passive entity that consists of a set of instructions written in a programming language. It is stored as an executable file on the disk and does not perform any action until executed.
Characteristics of a Program:
✅ Passive Entity: Exists in secondary storage (hard drive, SSD).
✅ Static in Nature: Does not change unless modified by the user.
✅ Executable File: Needs to be loaded into memory to run.
✅ No Resource Utilization: Does not use CPU, memory, or I/O unless executed.
✔ Example:
- A C program (file) stored as
program.c
is just a set of instructions. - An MS Word application (winword.exe) is an installed program until you open it.
2. What is a Process?
A process is an active entity that represents the execution of a program. When a program is loaded into memory and starts running, it becomes a process.
Characteristics of a Process:
✅ Active Entity: Resides in memory (RAM) and executes instructions.
✅ Dynamic in Nature: Changes state during execution.
✅ Consumes Resources: Requires CPU, memory, and I/O to run.
✅ Has a Unique Process ID (PID): Assigned by the OS for identification.
✔ Example:
- When you double-click MS Word (
winword.exe
), the program is loaded into memory, and a process is created. - Running
gcc program.c
starts a compiler process in Linux.
3. Key Differences: Program vs. Process
Feature | Program | Process |
---|---|---|
Definition | A set of instructions stored in a file | A running instance of a program |
Nature | Passive | Active |
Location | Stored in secondary memory (HDD/SSD) | Resides in RAM |
State Changes | Does not change | Changes (New, Ready, Running, Waiting, Terminated) |
Resource Usage | No CPU or memory usage | Uses CPU, memory, and I/O |
Instance | A single program can have multiple instances | Each process is a separate instance |
Example | a.exe , chrome.exe , program.c | Running Chrome browser, MS Word, gcc compiler process |
4. Life Cycle of a Process
A process goes through multiple states in its lifecycle:
1️⃣ New: Process is created but not yet ready to execute.
2️⃣ Ready: Process is loaded in RAM, waiting for CPU allocation.
3️⃣ Running: The process is actively executing on the CPU.
4️⃣ Waiting (Blocked): The process is waiting for I/O or another resource.
5️⃣ Terminated (Exit): Process execution is completed or killed.
✔ Example:
- When you open Google Chrome, it moves from New → Ready → Running.
- If waiting for internet, it moves to Waiting (Blocked).
- Closing it moves it to Terminated.
5. Relationship Between Program and Process
A single program can create multiple processes.
✔ Example:
- Google Chrome (a single program) can have multiple processes for different tabs.
- Running
gcc program.c
twice creates two compiler processes.
6. Conclusion
🔹 A program is a static file, while a process is its execution.
🔹 A process consumes system resources, whereas a program does not.
🔹 Multiple processes can originate from the same program.