🧠 Key Idea:
A program is just a passive set of instructions stored on disk.
A process is an active execution of that program, managed by the OS.
🧩 Difference Between Process and Program
| Feature | Program | Process |
|---|---|---|
| 🧾 Definition | Static code (e.g., .exe, .class, .py) | A program in execution |
| 💾 Location | Stored on disk | Loaded into RAM |
| 🧠 State | No state — just code | Has state — registers, PC, memory |
| 🔁 Instance | One program can be run many times | Each run creates a new process |
| ⏱️ Execution | Not running until loaded | Actively using CPU and RAM |
| 🧪 Example | code.exe in your file system | An open VS Code window with a PID |
| 🧰 Resources | Doesn’t use any until launched | Needs memory, CPU, file handles |
🎯 Real-World Analogy
-
A program is like a recipe in a cookbook.
-
A process is you actively cooking using that recipe in your kitchen.
- You’ve got ingredients out (memory), timer running (PC), and pans on the stove (I/O handles).
🧪 Real-Life Example
# This is the program:
$ which python
/usr/bin/python
# This is a process:
$ python3
>>> import os
>>> os.getpid()
30924-
The file
/usr/bin/pythonis the program. -
When you run it, it becomes a process with PID 30924.
⚠️ One Program, Many Processes
$ open 3 browser windows
-
Still 1 Firefox program on disk.
-
But each window may spawn a separate process (isolation, performance).
🧠 Interview-Ready One-Liner:
A program is a static set of instructions stored on disk, while a process is a dynamic instance of that program in execution, complete with memory, registers, and OS-managed resources.