Phase 7Ch 7.2 Mixed practice≈ 40 min
Twelve questions from all phases, mixed on purpose so you must first recognise which idea each needs. Conventions as in the front matter (times in ms, KB = 2¹⁰ bytes, ties to the earlier arrival).
12 questions · 20 marks · 40 minutes. Negative marking on MCQ only: −1/3 mark for a wrong 1-mark MCQ, −2/3 for a wrong 2-mark MCQ. No negative marking for MSQ or NAT; MSQ has no partial credit.
Q1 · NAT · 1 mark(s) — Address bits
How many address bits are needed for 512 MB of byte-addressable memory?
Numerical answer: ________
Q2 · MCQ · 1 mark(s) — Privileged instructions
Which instruction must be privileged (kernel mode only)?
- (A) Change the page-table base register
- (B) Execute a trap to make a system call
- (C) Add two registers
- (D) Load a value from memory into a register
Q3 · NAT · 2 mark(s) — fork()
How many characters in total does this print? fork(); fork(); printf("A"); fork(); printf("B");
Numerical answer: ________
Q4 · MCQ · 1 mark(s) — Threads
Which of these is NOT shared by the threads of one process?
- (A) Global variables
- (B) The stack
- (C) Open files
- (D) The heap
Q5 · NAT · 2 mark(s) — SRTF
P1 (arrival 0, burst 6), P2 (1, 3), P3 (2, 1), P4 (3, 4). SRTF: average waiting time?
Numerical answer: ________
Q6 · NAT · 2 mark(s) — Round robin
Same processes (P1 0/6, P2 1/3, P3 2/1, P4 3/4), RR with quantum 2. Completion time of P1?
Numerical answer: ________
Q7 · NAT · 2 mark(s) — Race
x = 1. Thread 1 runs x = x * 3, thread 2 runs x = x + 2, each as load/compute/store. How many different final values are possible?
Numerical answer: ________
Q8 · MCQ · 2 mark(s) — Bounded buffer
A bounded buffer has 5 slots (empty = 5, full = 0 at first). The producer has added 7 items and the consumer removed 3, and nobody is waiting. Values of (empty, full)?
- (A) (2, 3)
- (B) (5, 0)
- (C) (1, 4)
- (D) (4, 1)
Q9 · NAT · 2 mark(s) — Banker's
11 units of one resource. A holds 3 (max 7), B holds 4 (max 6), C holds 2 (max 5). How many units are free right after the first process of a safe sequence finishes?
Numerical answer: ________
Q10 · NAT · 1 mark(s) — Minimum resources
6 processes each need at most 3 units of one resource. Minimum number of units that rules out deadlock?
Numerical answer: ________
Q11 · NAT · 2 mark(s) — LRU
Reference string 1 2 3 2 4 1 5 2 1 2 3 4, 4 empty frames, LRU. Number of page faults?
Numerical answer: ________
Q12 · NAT · 2 mark(s) — SSTF
Head at 80; requests 45, 130, 10, 175, 90, 60, 150 (SSTF). Total head movement?
Numerical answer: ________
✓Answer Vault
Try the questions first. Open when you are ready to check.
🔐 Open the Answer Vault
Q1 Answer: 29 · 1 mark(s)
512 MB = 2⁹ × 2²⁰ = 2²⁹ bytes.
Re-read: Lesson 0.1.1 — Inside a computer: CPU, memory, disk, I/O; bits, bytes and powers of two
Q2 Answer: (A) · 1 mark(s)
It controls memory protection for every process.
- (B) is wrong: The trap is how user programs enter the kernel.
- (C) is wrong: Ordinary user instruction.
- (D) is wrong: Ordinary user instruction.
Re-read: Lesson 0.1.2 — What an operating system does: kernel, user mode and kernel mode, interrupts
Q3 Answer: 12 · 2 mark(s)
4 processes print A; each forks, so 8 print B.
Re-read: Lesson 1.1.2 — Creating processes with fork(), exec() and wait(); context switches and schedulers
Q4 Answer: (B) · 1 mark(s)
Each thread has its own stack, registers and program counter.
- (A) is wrong: Shared.
- (C) is wrong: Shared.
- (D) is wrong: Shared.
Re-read: Lesson 1.2.1 — Threads: what they share, user-level vs kernel-level threads
Q5 Answer: 2.75 · 2 mark(s)
P1 0–1, P2 1–2, P3 2–3, P2 3–5, P4 5–9, P1 9–14: waits 8, 1, 0, 2.
Re-read: Lesson 2.1.2 — Shortest job first and shortest remaining time first
Q6 Answer: 12 · 2 mark(s)
P1 0–2, P2 2–4, P3 4–5, P1 5–7, P4 7–9, P2 9–10, P1 10–12, P4 12–14.
Re-read: Lesson 2.2.1 — Round robin and the time quantum
Q7 Answer: 3 · 2 mark(s)
5 and 9 (one after the other) and 3 (both read 1).
Re-read: Lesson 3.1.1 — Race conditions and the critical-section problem
Q8 Answer: (C) · 2 mark(s)
empty = 5 − 7 + 3; full = 7 − 3.
- (A) is wrong: Miscounted.
- (B) is wrong: The initial values.
- (D) is wrong: Swapped.
Re-read: Lesson 3.2.2 — Classic problems: bounded buffer, readers–writers, dining philosophers
Q9 Answer: 6 · 2 mark(s)
Free 2; only B (needs 2) can finish first and returns its 4.
Re-read: Lesson 4.1.2 — Prevention and avoidance: safe states and the banker's algorithm
Q10 Answer: 13 · 1 mark(s)
6 × 2 + 1.
Re-read: Lesson 4.1.3 — Detection, recovery, and the minimum-resources formula
Q11 Answer: 7 · 2 mark(s)
1, 2, 3, 4 load; 5 evicts 3; 3 evicts 4; 4 evicts 5.
Re-read: Lesson 5.3.2 — Page replacement: FIFO, optimal and LRU; Belady's anomaly
Q12 Answer: 255 · 2 mark(s)
80 → 90 → 60 → 45 → 10 → 130 → 150 → 175.
Re-read: Lesson 6.2.2 — Disk scheduling: FCFS, SSTF, SCAN, C-SCAN, LOOK, C-LOOK