- LPU MCA Semester 1
- CAP366
- Unit 3
CAP366 · Unit 3: Process management
Process control block
10 practice questions · in the MTE and ETE syllabus
Key points
- PCB = kernel's record of a process
- Holds state, PID, PC, registers, memory and I/O info
- Created at process creation, freed after wait()
- Does not hold the program's code
The PCB (task_struct in Linux) is the kernel's record of a process. It lives in kernel memory from creation until the parent collects the exit status.
Typical fields: process state, process ID and parent ID, program counter, CPU registers, scheduling information (priority, queue pointers), memory-management information (page tables, base/limit), accounting information and I/O status (open files, devices).
| Field group | Used for |
|---|---|
| State, PID, PPID | Identification and scheduling decisions |
| PC and registers | Resuming exactly where it left off |
| Memory info | Restoring the address space |
| Accounting / I/O | Billing, open files |
Example: a table for 500 processes with 1.5 KB PCBs reserves 500 x 1.5 = 750 KB.
Exam pitfall: the PCB does not contain the program's source or data; it holds the information needed to manage and resume the process. After fork the child gets a new PID but a copy of most other fields.
Try two questions
A parent calls fork(). Which PCB field of the child must differ from the parent's copy?
- Scheduling priority
- Process identifier (PID)
- List of open files
- Saved program counter
Show the answer
B. Each process needs a unique PID, so the child's PID differs. Priority, open files and the program counter are initially copied.
Why not A: The child normally inherits the parent's priority.
Why not C: The child inherits copies of the parent's open file descriptors.
Why not D: Right after fork both processes resume at the same instruction.
Why does the OS keep each PCB in kernel memory rather than in the process's own address space?
- The saved registers would be too large to fit on the user stack of any process
- The kernel cannot read the user address space while the process is not running
- Kernel memory is fast enough for the whole context switch to finish in one cycle
- A user process could otherwise alter its saved state, priority or page tables and break protection
Show the answer
D. If the PCB were user-writable, a program could change its priority or memory mappings. Keeping it in kernel memory protects the OS.
Why not A: The saved state is small, and size is not the reason.
Why not B: The kernel can access user memory whenever it needs to.
Why not C: A context switch takes many cycles regardless of where the PCB lives.