Process vs program & the PCB
Scenario
You can open Google Chrome five times, creating five different windows. It's only one program on your hard drive, but the operating system tracks it as five distinct, living entities.
Mental model
A Program is a recipe; a Process is the act of cooking that recipe.
A recipe (program) just sits on the shelf as passive text. When you start cooking (process), you need ingredients (memory), a chef's current step (CPU program counter), and a workspace. The PCB is the clipboard where the chef tracks exactly what step they are on in case they need to pause and cook something else.
Explanation
In computer science, distinguishing between a program and a process is fundamental. A 'program' is a passive entity—it is a static file sitting on your hard drive containing a list of compiled machine code instructions. A 'process', on the other hand, is an active entity. It is a program in execution. When you double-click an executable file, the operating system loads those static instructions into RAM, allocates resources, and the CPU begins executing it. At that moment, the passive program becomes an active process.
Because you can run the same program multiple times simultaneously (like having multiple instances of a calculator or terminal open), one program can spawn many separate processes. Even though they execute the exact same underlying code, each process is completely independent. They have their own dedicated memory space, their own variables, and their own execution state. If one calculator process crashes because you divided by zero, the other calculator process remains entirely unaffected.
To manage all these independent active processes, the operating system needs a way to keep track of them. It does this using a critical data structure called the Process Control Block (PCB). Think of the PCB as the ID card and medical record for a process. Every time a new process is created, the OS creates a new PCB specifically for it.
The Process Control Block stores all the essential metadata required to manage that process. This includes the Process ID (PID), the current state of the process (running, waiting, or ready), memory allocation details, and a list of open files. Crucially, the PCB also stores the exact contents of the CPU registers and the Program Counter (which tracks the exact line of code currently being executed).
This register and Program Counter data is what makes multitasking possible. Because a computer has limited CPU cores, the OS must rapidly switch the CPU between dozens of processes. When it pauses Process A to run Process B, it copies the CPU's current state into Process A's PCB. Later, when the OS is ready to resume Process A, it reads the PCB, restores the exact CPU state, and the process continues exactly where it left off, completely unaware that it was ever paused.
Common mistakes
- Using 'program' and 'process' interchangeably: A program is static bytes on a disk. A process is a running instance of that program in RAM. You can have 1 program but 10 processes running it.
- Assuming processes share memory by default: Each process is strictly isolated by the OS. Variables in one process cannot be read or modified by another process. If they need to share data, they must use specific Inter-Process Communication (IPC) methods.
Glossary
- passive entity
- Something that is inactive and just sitting in storage, much like a recipe written in a book that isn't currently being cooked.
- machine code instructions
- The lowest-level, raw binary commands (1s and 0s) that a computer's processor can directly understand and execute.
- active entity
- A program that has been woken up, loaded into fast memory, and is actively executing actions, like a chef actively cooking a recipe.
Recall questions
- What is the core difference between a program and a process?
- What is a Process Control Block (PCB)?
- Why does the PCB need to store the Program Counter and CPU registers?
Questions & answers
Which of the following pieces of information is NOT typically found in a Process Control Block (PCB)?
The hard drive's master boot record.
Approach: The PCB contains process-specific metadata like the Process ID (PID), program counter, register states, memory limits, and open file descriptors. The master boot record is OS-level hardware data, not tied to a specific process.
If you open two instances of the same web browser, do they share the same PCB?
No, they are independent processes.
Approach: Even if two processes are executing the same program code, the operating system treats them as entirely separate entities. Each instance gets its own unique Process ID, isolated memory space, and its own unique Process Control Block.