Start here
exec, fork, and memory sharing.Program vs process (definitions)
The program is the executable image: ELF segments, dynamic linker metadata, maybe an interpreter path. Nothing here “runs” until the loader maps pages and the CPU fetches the entry point.
The process adds execution state: program counter, stack pointer, heap arenas grown via brk/mmap, file descriptor table, and signal masks. Two processes can map the same binary read-only and still havedifferent address spaces and lifetimes.
By the end of this page you should be able to
- Explain how the same file on disk can back multiple concurrent processes.
- Describe what changes across `execve` while PID may stay the same.
- Name two things that live only in the process, not in the program file.
CoW (copy-on-write) after fork lets parent and child share physical frames for read-only text until one writes, then private copies materialize. That is a performance trick, not “the same process.”
Operating systems · Processes
Process vs program
Static file vs live execution context
TL;DR
A program is bits on disk (ELF segments, metadata); a process is those segments mapped into a private virtual address space with CPU state, fds, and kernel linkage, multiple processes can run the same program file concurrently.
Summary
Interviewers use this question to see if you confuse files with runtime state. Emphasize mapping, per-process tables, and the fact that scheduling and signals attach to tasks, not to inode numbers.
Deeper narrative
The program is static artifacts on disk (ELF segments, metadata); the process is dynamic execution state including brk/mmap arenas, stack, registers, and kernel bookkeeping. Multiple processes can map the same binary read-only with shared text pages.
Mechanism (step by step)
Loader maps ELF
Interpreter or direct map PT_LOAD segments; dynamic linker resolves PLT/GOT.
Kernel creates task
Allocates mm, fd table, sets credentials from parent or file capabilities.
Execution advances PC
Instructions mutate registers and memory; program counter alone is not the whole story.
Persistence vs volatility
Program bytes on disk survive reboot; process RAM does not unless checkpointed.
Key insights
Many-to-one mapping
Dynamic linking
Scripts need interpreters
Containers still run programs
Did you know?
Common pitfalls
“Same binary ⇒ same process”
Each exec creates a new address space; shared libraries may dedupe physical frames but remain separate VAs.
Ignoring ASLR
Same program text may load at different virtual addresses per exec for security.
Glossary
ELF
CoW
Address space
Interview follow-ups
- Why can two processes share physical pages for libc text yet remain isolated?
- What distinguishes a script process from its interpreter process?
- How does `MAP_PRIVATE` affect sharing of file-backed pages?
Callouts
Crisp answer template
“Program = file; process = loaded image + resources + threads; many processes can share one program file.”
Walkthrough & deep dive
Left: practical “how would I use this?” threads. Right: slower, code-leaning explanations, open one panel at a time so the page does not feel like a wall of sameness.
Walkthrough
Whiteboard
Deep dive
ELF segments
`.text` (code), `.rodata`, `.data`, `.bss`, heap (brk/mmap), stack, vDSO, each has permissions the MMU enforces.
Same binary, two PIDs
/bin/sleep 100 &/bin/sleep 100 &pgrep -a sleep
Self-check
1Two processes running the same binary typically…
2Which uniquely identifies a running instance?
3The loader primarily…