Process Management MCQs for NSCT
Process management is how the OS creates, tracks, switches between and ends processes. A process is a program in execution, and the OS records each one in a process control block (PCB). This is topic 3 of the Operating Systems area, which carries 5% of the NSCT according to HEC's Areas of Competencies. OS had the lowest 2026 accuracy of any area, 33.8%, per the HEC NSCT report and APP.
Definitions follow Silberschatz, Operating System Concepts. A process in memory has four sections: text (code), data (global variables), heap (memory from malloc()) and stack (parameters, return addresses and local variables). A program on disk is passive. Once it is loaded and running, it is a process.
Process states
Silberschatz uses five states:
| State | Meaning |
|---|---|
| New | Being created |
| Ready | Waiting to be given a CPU core |
| Running | Instructions are executing |
| Waiting | Waiting for an event, such as I/O completion |
| Terminated | Finished execution |
The legal transitions are: new → ready (admitted), ready → running (dispatched by the scheduler), running → ready (interrupt, such as the timer), running → waiting (I/O or event wait), waiting → ready (I/O or event completion) and running → terminated (exit).
Two moves never happen directly: waiting → running and ready → waiting. A finished I/O puts a process back in the ready queue, and only a running process can ask to wait. Textbooks differ on names. Stallings says "blocked" for waiting and adds suspended states in a seven-state model.
Three schedulers act on these states. The short-term (CPU) scheduler picks from the ready queue very often. The long-term (job) scheduler admits jobs and controls the degree of multiprogramming; Silberschatz notes that UNIX and Windows have little or none. The medium-term scheduler swaps processes out and back in when memory is tight.
Exam angle: "I/O completes while another process is running." The waiting process becomes ready, not running.
PCB
The process control block is the kernel's record of one process. It holds:
- process state and process ID
- program counter (the address of the next instruction)
- CPU registers
- CPU-scheduling information (priority, queue pointers)
- memory-management information (base and limit registers or page tables)
- accounting information (CPU time used)
- I/O status (open files, allocated devices)
In Linux the PCB is the task_struct. It lives in kernel memory, so a process cannot edit its own priority. It does not contain the stack or heap themselves.
Exam angle: "Which is NOT in the PCB?" The answer is usually the actual data (stack contents, heap, source code), not a pointer or a register value.
Context switching
A context switch saves the running process's state into its PCB and loads the next process's state from its PCB. It is pure overhead, because no process does useful work meanwhile. Hardware with several register sets makes it faster. A context switch is not the same as a mode switch. A system call enters kernel mode but may return to the same process.
Overhead matters when slices are short: a 10 ms slice with a 1 ms switch wastes 1/11, about 9.1%, while a 0.5 ms slice with a 0.5 ms switch wastes 50%. CPU Scheduling picks this up.
Exam angle: divide by the whole cycle (slice + switch), not by the slice alone.
Process creation and termination
fork() creates a child with a copy of the parent's address space. It returns 0 in the child and the child's PID in the parent (−1 on failure). exec() replaces the memory image with a new program and keeps the PID. wait() lets a parent collect a child's exit status.
| Code | Processes | Prints |
|---|---|---|
n plain fork() calls, then printf |
2ⁿ | 2ⁿ |
fork() && fork(); |
3 | 3 |
fork() \|\| fork(); |
3 | 3 |
fork() && fork() \|\| fork(); |
5 | 5 |
loop i < 3 with fork(); printf inside |
8 | 2 + 4 + 8 = 14 |
We checked every count on this page by simulating the full fork tree in Python. Because each process has its own copy of variables, a child's x++ never changes the parent's x.
A zombie has exited, but its parent has not yet called wait(). An orphan's parent has exited; Linux and UNIX re-parent it to init (or systemd), which reaps it.
Common traps
- Moving a process straight from waiting to running after I/O completes.
- Forgetting short-circuit evaluation: in
fork() && fork(), the child skips the second fork. - Counting children as 2ⁿ. For n forks, 2ⁿ is the total process count, and the children number 2ⁿ − 1.
- Assuming the parent sees a child's variable change. Address spaces are copied, not shared.
- Mixing up zombies (child dead, parent alive and not waiting) with orphans (parent dead).
- Expecting code after a successful
exec()to run. It never returns.
Worked examples
Understanding. Which PCB field tells the CPU where to resume a process after a context switch? Answer: the program counter. It holds the address of the next instruction. The saved registers restore the rest of the CPU state.
Application. A loop runs fork() 4 times (for (i = 0; i < 4; i++) fork();), then calls printf("x\n"). How many times is x printed?
Answer: 16. Every existing process forks in each iteration, so the count doubles 4 times: 2⁴ = 16 processes, each printing once.
Analysis. How many times does fork(); fork() && fork(); printf("x\n"); print x?
Answer: 6. The first fork() gives 2 processes. Each then runs fork() && fork(), which turns 1 process into 3 (the first child short-circuits). So 2 × 3 = 6 processes print.
Practise
The quiz below has 100 Process Management questions, which you can filter by tier and difficulty.
Practise: 100 questions
FAQs
What is the difference between a process and a program?
A program is a passive entity, an executable file stored on disk. A process is an active entity: the program loaded into memory with its own program counter, registers, stack, heap and PCB. One program can give rise to many processes. For example, three users running the same editor create three processes.
What is the difference between a zombie and an orphan process?
A zombie has finished, but its parent has not yet called wait(), so its process-table entry and exit status remain. An orphan is still running, but its parent has exited. Linux and UNIX re-parent orphans to init or systemd, which calls wait() when they finish, so they do not stay zombies.
Why does fork() return two different values?
After fork() there are two processes running the same code, and each needs to know which one it is. The child receives 0, and the parent receives the child's PID so it can track or wait for that child. Testing if (fork() == 0) is the standard way to give the child different work.
Is a context switch the same as switching to kernel mode?
No. A mode switch happens on every system call or interrupt, and the kernel may return to the same process. A context switch happens only when the CPU moves to a different process. Every context switch involves kernel mode, but most mode switches are not context switches.
Next step
Continue with CPU Scheduling MCQs, go back to the Operating Systems hub, or try a timed NSCT mock test.