A program is a static set of instructions written in a programming language such as C, C++, or Go. It is stored in a file—often a binary with an .exe
extension on Windows—and is the output of a compilation process. Examples of programs include Notepad, VSCode, or a custom-built application. The source code of a program represents the logic and behavior a programmer wants the operating system to execute when the program is run.
In contrast, a process is a program in execution.
A process is an instance of a program that is being executed by the operating system.
This definition is technically correct but oversimplified. It doesn't fully reflect the complexities involved when a program transitions to a running process.
When you execute a program, the operating system loads it into memory and creates a process. This process is more than just the code—it consists of several memory segments collectively referred to as the process layout:
The OS reads instructions from the TEXT segment and begins executing them—loading variables into CPU registers, performing computations, making system calls, and updating memory. Any runtime-created data (like objects, buffers, etc.) gets stored in the HEAP or STACK depending on how it's allocated.
When the same program is run multiple times (e.g., opening two instances of Notepad), the OS creates separate processes for each execution. Each process has:
This allows the same program to run concurrently in isolation, without interference between instances.
What’s described here is just the tip of the iceberg. Processes involve complex scheduling, inter-process communication (IPC), synchronization, privilege separation, and more. Running processes reliably and concurrently is one of the most important and intricate responsibilities of an operating system.