The Process Concept, Memory Layout & The PCB
“How the OS breathes life into passive disk binaries, structuring virtual memory and PCB control blocks.”
1.Program vs. Process: The Fundamental Separation
§ 2.1.A program is completely passive: it is a collection of compiled bytes, instructions, and static data resting silently in secondary storage (like an executable .exe or ELF binary on disk).
A process, in contrast, is an active entity. It is a program in execution, endowed with its own virtual address space, a Program Counter tracking its next instruction, CPU register states, open file descriptors, and dedicated memory segments.
Think of a program as a written musical score resting in a drawer; a process is the orchestra actively performing that score in real time.
A cookbook recipe is a program. The chef reading the recipe, utilizing kitchen tools, and tracking current progress is the process.
2. The Anatomy of Process Memory
Draw low memory base: Text / Code segment (binary machine instructions).
Lowest memory addresses. Read-only to prevent self-modifying code. Shared among multiple running instances.
Placing Code segment at high memory.
3.The Four Core Memory Segments
§ 2.3.Text Segment (Code): Contains the compiled machine instructions. This region is read-only and often shared among multiple instances of the same program to conserve physical RAM.
Data & BSS Segments: The initialized data segment holds global and static variables explicitly given values (e.g. int count = 10;). The BSS (Block Started by Symbol) segment stores uninitialized globals/statics, zero-initialized by the OS loader.
Heap Segment: Dynamically managed memory allocated at runtime via system calls (malloc(), calloc(), new). The heap grows upward from lower memory toward higher addresses.
Stack Segment: Holds local function call frames, parameters, local variables, and return addresses. On standard architectures (like x86/ARM), the stack grows downward from high memory toward lower addresses.
4. The Process Control Block (PCB)
5. Architecture Comparison: Process vs. Thread
Understanding the exact resource boundaries is critical for both systems programming and GATE questions.
| Feature / Aspect | Process | Thread (Lightweight Process) |
|---|---|---|
| Address Space | Isolated, private virtual memory space. | Shares code, data, heap, and open files with peer threads. |
| Creation Overhead | Heavyweight: Requires memory allocation, page tables, PCB creation. | Lightweight: Minimal state allocation (private stack & TCB only). |
| Context Switching | Slow: Flushes TLB cache, switches page tables (CR3) & registers. | Fast: Switches only registers and stack pointer; TLB intact. |
| Failure Isolation | High: One process crashing does not affect other processes. | Low: An illegal memory access in one thread crashes all peer threads. |
✎ Takeaway: Processes provide units of resource ownership and isolation; threads provide units of CPU dispatching and scheduling.
6. GATE Lens & Verified PYQs
Syllabus focus, recurring numerical patterns, common traps, and clearly labelled exam practice. Questions remain source-pending until an official paper and answer key are attached.
Memory segment classification and thread resource sharing appear frequently in GATE CS (notably 2011, 2017, and 2021).
- •Identifying which segment a given variable is allocated in (global, local, static, dynamic).
- •Determining what program state is shared between threads vs kept strictly private.
- •Forgetting that static local variables inside functions live in the DATA/BSS segment, NOT on the stack!
- •Pointers allocated with
mallochave their pointer variable on the stack, but the pointed-to buffer on the heap.
Exam Practice / Source Verification Required
1 problemWhich of the following components of a program state are NOT shared among threads of the same process? (P) Code segment (Q) Global variables (R) Stack (S) CPU Register values
7. 1-Minute Panic Revision
“Process = Program in execution with isolated virtual address space (Text + Data/BSS + Heap + Stack) + PCB.”
- •Stack grows DOWNWARD (High → Low addresses); Heap grows UPWARD (Low → High addresses).
- •Threads SHARE: Code, Globals/BSS, Heap, Open files.
- •Threads KEEP PRIVATE: Stack, Registers, Program Counter (PC).
- •Static variables (even inside a local function block) live in DATA/BSS, never on the stack.
- •PCB is maintained exclusively in kernel space; user code cannot read or overwrite its own PCB.
Primary Academic References & Exam Sources
Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.
Official slides showing the memory layout (Text, Data, BSS, Heap, Stack) and Process Control Block fields.
Clear introduction to process address space initialization, PCB structures in xv6, and process APIs.
If the textbook derivation did not click immediately, consult these targeted video lessons:
Practical breakdown of what goes into Data vs BSS vs Stack vs Heap with C memory examples.
Clean blackboard lecture showing what threads share in RAM versus what remains private (registers, PC, stack).
Curated lectures on Process Lifecycle, PCB Memory Layout, Fork() System Calls & Multi-threading Models:
Rapid intuitive mastery of process state transitions and state diagram numericals.
Clear breakdown of blocking I/O behavior, thread context switches, and kernel space mapping.
Visual tree diagram derivations of fork() return values and process hierarchies.
Exam trick cases on how many times printf() executes in tricky fork() loops.