🧠 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

FeatureProgramProcess
🧾 DefinitionStatic code (e.g., .exe, .class, .py)A program in execution
💾 LocationStored on diskLoaded into RAM
🧠 StateNo state — just codeHas state — registers, PC, memory
🔁 InstanceOne program can be run many timesEach run creates a new process
⏱️ ExecutionNot running until loadedActively using CPU and RAM
🧪 Examplecode.exe in your file systemAn open VS Code window with a PID
🧰 ResourcesDoesn’t use any until launchedNeeds 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/python is 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.