4.2.4 · D5Operating Systems

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

1,900 words9 min readBack to topic
Figure — Processes — PCB, states (new - ready - running - blocked - terminated)

True or false — justify

Every process in the Ready state is waiting for the CPU and nothing else.
True — Ready means "has everything except a free core." If it needed data from disk too, it would be Blocked, not Ready.
A blocked process is using CPU time while it waits.
False — a Blocked process holds zero CPU. That is the entire point: instead of idle-spinning on the core it steps aside so the scheduler can run someone useful.
There can be several processes in the Running state at the same instant on a single-core machine.
False — exactly one process runs per core at a time. Multiple "Running" only makes sense with multiple cores.
There can be many processes in the Ready state at once.
True — the ready queue is a queue precisely because many processes can be dispatch-eligible simultaneously; the CPU picks one.
The PCB (Process Control Block) stores the actual machine-code instructions of the program.
False — the code (text segment) lives in the process's memory image; the PCB stores metadata plus a pointer to that image. The PCB is small even for a huge program.
Two different running programs can share one PCB if they run the same executable.
False — there is one PCB per process. Running the same program twice creates two processes, two PIDs, two PCBs.
A process must pass through Ready before it can ever run.
True — dispatch is defined as Ready → Running. Even a brand-new process goes New → Ready → Running; nothing jumps New → Running.
When a process's time-slice expires it becomes Blocked.
False — timeout sends it to Ready. It is still perfectly able to run; it merely lost its turn. Blocked is reserved for waiting on an external event.
When I/O completes, the process resumes running immediately.
False — it goes Blocked → Ready. The core may be busy with another process, so the scheduler must re-select it first.
Terminated processes still have a PCB, at least briefly.
True — the state is recorded as Terminated in the PCB; the OS keeps that record until the exit info is collected, then reclaims it. It isn't erased the instant the process ends (see the Zombie edge case).
A context switch performs useful user computation.
False — the save (PC + registers into the old PCB) and restore (from the new PCB) is pure overhead; no user instructions execute during it. Too many switches waste CPU.
Every state transition is triggered by the process itself.
False — some are voluntary (calling I/O → Blocked), but preemption (Running → Ready) is forced on the process by a timer interrupt handled by the kernel, not requested by it.

Spot the error

"Running → Blocked → Running when the disk finishes."
The middle-to-last hop is illegal. Correct path: Running → Blocked → Ready → Running. Blocked never jumps straight to Running.
"On preemption we save the PC into the ready queue."
The PC (Program Counter) is saved into the process's PCB, not the queue. The ready queue holds pointers to PCBs, not register values.
"New → Running as soon as the process is created."
A created process becomes Ready first (the "admit" transition), then Running via dispatch. No New → Running edge exists.
"Ready → Blocked because it's been waiting too long for the CPU."
No such transition. Waiting for the CPU is Ready; it never becomes Blocked from mere queue delay. Blocked requires an external event to wait on.
"We don't need to save registers on a timeout because the process will just start over."
Fatal — the process must resume exactly where it stopped. Losing the registers/PC corrupts its mid-calculation state and it would execute garbage.
"Blocked → Terminated is impossible."
Actually possible — a process can be killed while blocked (e.g. the OS or a signal terminates it). Its pending I/O is abandoned and the PCB is reclaimed.
"Two cores means two Running and everyone else is Blocked."
Wrong split — the rest are mostly Ready (waiting for a core), not Blocked. Blocked is only for those awaiting an event.
"The scheduler chooses which process to move from Blocked to Ready."
No — the event completion (I/O interrupt) moves Blocked → Ready. The scheduler's job is choosing among Ready processes for the CPU.

Why questions

Why does I/O completion send a process to Ready instead of Running?
Because the CPU may already be executing another process; forcing a resume would require kicking that one off arbitrarily. Re-queuing keeps scheduling fair and consistent.
Why is the PC (Program Counter) the single most critical PCB field?
It names the next instruction. Without it, on resume the CPU has whatever address the previous process left, so the process jumps into the wrong code and crashes.
Why separate "Blocked" from "Ready" at all — why not one waiting state?
They wait on different things. Ready is dispatch-eligible now; Blocked cannot run until an event fires. The scheduler must never dispatch a Blocked process, so they need distinct labels.
Why is a "New" state needed instead of going straight to Ready?
Creation takes work — allocate the PCB, set up the address space, load the image. During that setup the process isn't dispatchable yet, so it sits in New.
Why is excessive context switching harmful?
Each switch is overhead with no user progress; if switches dominate, the CPU spends its time saving/restoring PCBs instead of doing work — throughput collapses.
Why does a preempted process go to Ready rather than being destroyed?
It hasn't finished — it just used its time-slice. It still holds valid state and needs the CPU again, so it rejoins the ready queue.
Why can't the PCB just live inside the process's own memory that the process can edit?
The PCB is kernel bookkeeping; if a process could rewrite its own state/PID/priority it could cheat the scheduler or corrupt the system. It therefore lives in kernel space — memory the kernel (the trusted core of the OS) protects from user programs.
Why does the state itself get stored in the PCB rather than tracked elsewhere?
The OS must answer "what is this process doing?" instantly for scheduling, and the PCB is the one per-process record it already holds, so the state lives there beside the PC and registers.

Edge cases

A process is created but the system is out of memory to build its image — where is it?
It is stuck in (or fails out of) New; admission to Ready only happens once resources are allocated. It never becomes Ready if setup can't complete.
A process runs, immediately calls exit() on its first instruction — which states did it visit?
New → Ready → Running → Terminated. It never blocked; the shortest real lifecycle still passes through Ready and Running.
A CPU-bound loop with no I/O and no other processes — does it ever leave Running?
Yes, on timeout/preempt (timer interrupt) it goes Running → Ready even with no rivals, then is re-dispatched. It never enters Blocked because it never waits on an event.
A process requests I/O — when does it Block, and when does it not?
It Blocks only if the I/O is synchronous and the data is not yet available (e.g. an actual disk read that must go to the platter). If the request is served instantly from an OS cache (data already in memory) or is asynchronous, the call returns without waiting, so the process stays Running and skips the Blocked → Ready path entirely.
What is the "Zombie" (defunct) state, and how does a process reach it?
On systems like Linux, when a process finishes it becomes a Zombie — it has stopped executing but its PCB is kept alive so its parent can read its exit code (called "reaping"). It sits between Terminated and full removal; once the parent reaps it, the PCB is finally reclaimed. This is a real-world refinement of the single "Terminated" state.
A process is killed while Ready (before it ever ran) — legal?
Yes — Ready → Terminated is valid; a process can be terminated from Ready or Blocked, not only from Running. Its PCB is then reclaimed.
On a single-core machine, can zero processes be Running?
Yes — momentarily during a context switch, or when all user processes are Blocked (the idle process fills the gap). "Running" isn't guaranteed to be occupied by user work.
Every process is Blocked and the ready queue is empty — what runs?
Nothing runnable exists, so the CPU runs the idle process (a special always-ready placeholder) until an event moves someone Blocked → Ready.