4.2.4 · D1Operating Systems

Foundations — Processes — PCB, states (new - ready - running - blocked - terminated)

1,776 words8 min readBack to topic

Before you can read the parent note fluently, you need to own every word it throws at you. This page builds each one from nothing, in an order where each idea rests on the one before it.


0. The absolute starting point: what is a "program"?

The picture: a closed book on a shelf. It contains steps, but nobody is cooking.

We need this word because the parent note keeps saying "a process is not the program." You can't understand that sentence until "program" means something precise to you. (Deeper contrast: Program vs Process.)


1. From recipe to cooking: what "in execution" means

Figure — Processes — PCB, states (new - ready - running - blocked - terminated)

WHY the topic needs this distinction: the whole rest of the chapter — states, saving, resuming — only makes sense for something moving. A file on disk has no "state"; only an activity in progress can be "paused at line 100." Look at the figure: the same recipe (left) becomes two different live cookings (right) if two people start it — that's why one program can spawn many processes.


2. The two live extras you must name

To pause a cooking and resume it, ask: what would I need to write down? Two answers give us two essential symbols.

2a. The Program Counter (PC)

The picture: a bookmark. If you lose the bookmark, you don't know where to continue — you'd flip to a random page and cook garbage.

WHY: the parent note calls PC "the single most critical field." Now you know why: it is the answer to "where was I?" Without a name for it, you can't even state the resume problem.

2b. Registers

The picture: sticky notes on the cook's hand with half-done sums. Drop them and the calculation restarts wrong.

WHY: "resume exactly where it left off" means restoring these too, not just the PC.


3. Where the code and data actually live: memory & address space

Figure — Processes — PCB, states (new - ready - running - blocked - terminated)

WHY: the parent's biggest mistake callout ("the PCB stores the code") only clears up once you see that the code lives here, in the address space, and the PCB merely points at this kitchen — it doesn't contain it. The PCB is a sticky note; the kitchen is huge.


4. The bookkeeping card: the PCB

Now assemble every "thing to write down" onto one card.

The picture: a sticky note taped to each kid's chair listing where their show was paused and what snacks they had (the Feynman image from the parent).

WHY the topic needs it: without one agreed container, "save the process" would be vague. The PCB is the concrete answer.


5. The identity tag: PID

The picture: a jersey number. Two kids may watch the same show, but their jerseys differ.


6. The word "state"

The picture: a status light. Green = running, yellow = waiting in line, red = stuck. One light per process at a time.

WHY: the CPU can serve only one process per core, so at any instant most processes are not running. We need vocabulary for "not running, but why?"


7. The invisible hand: scheduler, dispatch, and interrupts

Figure — Processes — PCB, states (new - ready - running - blocked - terminated)

Three linked words the transitions rely on.

WHY: the arrows "dispatch," "timeout," "interrupt" in the parent's state diagram are meaningless until these actors have faces. The figure shows the scheduler as a hand moving a token from the Ready line onto the single CPU seat.


8. The reason processes ever stop voluntarily: I/O and events

WHY: this is exactly why the Blocked state exists. A process asks for slow data, and rather than freeze the whole CPU standing at the toaster, it steps aside (Blocked) until the pop (event) lets it rejoin the line. Deeper: Inter-Process Communication uses these same waits.


9. Save-and-restore: the context switch (preview)

WHY it belongs in foundations: every arrow into or out of Running is powered by a context switch. Knowing the word now means the state diagram reads as actions, not magic.


The prerequisite map

Here is how every foundation above feeds the parent topic. Read top-to-bottom: lower boxes depend on higher ones.

Program on disk

Process in execution

Program Counter

CPU registers

Address space

PCB index card

PID identity

Process state

Scheduler and dispatch

I O and events

Context switch

Processes states and PCB


Equipment checklist

Cover the right side and test yourself. If any answer is fuzzy, re-read its section before the main note.

What is a program (at rest)?
A file of instructions on disk, doing nothing — a recipe on paper.
What turns a program into a process?
Being executed — carried out live, with a current position and working values.
What does the Program Counter (PC) store?
The address of the next instruction — the cook's finger on the current recipe line.
What are CPU registers?
The CPU's few fast scratch slots holding the values it's working with right now.
What is a process's address space?
The memory region it may touch — its code, variables, and stack (the whole kitchen counter).
Does the PCB contain the code?
No — the code lives in the address space; the PCB only points to it.
What is the PCB, in one line?
The per-process index card holding PC, registers, state, PID, memory pointer, I/O and scheduling info.
What is a PID?
A unique number naming one process.
What is a "state"?
A one-word description of what a process is doing right now.
What does the scheduler do?
Picks which Ready process runs next; "dispatch" hands it the CPU.
What is an interrupt / timeout?
A signal that pulls the CPU away — a timeout means the time slice ended.
What is I/O and an "event"?
Talking to the slow outside world; the event is the moment that slow operation finishes.
What is a context switch?
Saving one process's PC+registers to its PCB and loading another's from its PCB.