Phase 7Ch 7.2 Mixed practice≈ 40 min
The last practice set. Time yourself: 1-mark questions under 90 seconds, 2-mark under 3 minutes.
12 questions · 18 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 · MCQ · 1 mark(s) — Timer
Why does the OS set a hardware timer before giving the CPU to a user program?
- (A) To measure the program's memory
- (B) To protect files
- (C) To speed up the program
- (D) So that a program can't keep the CPU for ever
Q2 · MCQ · 1 mark(s) — Zombie
A child process has exited, but its parent has not yet called wait(). The child is:
- (A) an orphan
- (B) suspended
- (C) a zombie
- (D) running
Q3 · NAT · 2 mark(s) — FCFS
FCFS: P1 (arrival 2, burst 4), P2 (3, 2), P3 (10, 3), P4 (11, 1). Average turnaround time?
Numerical answer: ________
Q4 · NAT · 2 mark(s) — CPU + I/O
FCFS on the CPU, separate I/O devices. A (arrival 0): CPU 3, I/O 5, CPU 2. B (arrival 0): CPU 2, I/O 1, CPU 4. When does A finish?
Numerical answer: ________
Q5 · MCQ · 1 mark(s) — Spinlocks
A spinlock is the better choice when:
- (A) critical sections are very short and there are several CPUs
- (B) critical sections are long and there is one CPU
- (C) processes must sleep while waiting
- (D) bounded waiting is required
Q6 · NAT · 2 mark(s) — Race with semaphore
x = 0. P1 and P2 each do x = x + 3; P3 does x = x − 1. Each brackets its read-modify-write with wait(S) … signal(S), and S starts at 2. Largest possible final value of x?
Numerical answer: ________
Q7 · MCQ · 1 mark(s) — Prevention
If the OS may take resources away from a waiting process, which deadlock condition is broken?
- (A) Circular wait
- (B) No pre-emption
- (C) Hold and wait
- (D) Mutual exclusion
Q8 · NAT · 2 mark(s) — Translation
Pages are 4 KB. Logical address 13,000 is on page p, and page p is in frame 11. Physical address?
Numerical answer: ________
Q9 · NAT · 2 mark(s) — Page-fault EAT
ma = 150 ns, page-fault service 5 ms, fault rate 2 × 10⁻⁵. EAT in ns (nearest integer)?
Numerical answer: ________
Q10 · NAT · 2 mark(s) — FIFO
Reference string 1 2 3 2 4 1 5 2 1 2 3 4, 4 empty frames, FIFO. Number of page faults?
Numerical answer: ________
Q11 · NAT · 1 mark(s) — Latency
A disk spins at 10,000 rpm. Average rotational latency in ms?
Numerical answer: ________
Q12 · NAT · 1 mark(s) — Interrupts
A device interrupts 2000 times per second and each interrupt costs 50 µs. Percentage of CPU time used?
Numerical answer: ________
✓Answer Vault
Try the questions first. Open when you are ready to check.
🔐 Open the Answer Vault
Q1 Answer: (D) · 1 mark(s)
The timer interrupt returns control to the OS.
- (A) is wrong: Unrelated.
- (B) is wrong: That is permissions.
- (C) is wrong: No.
Re-read: Lesson 0.1.2 — What an operating system does: kernel, user mode and kernel mode, interrupts
Q2 Answer: (C) · 1 mark(s)
Its entry stays until the parent collects the exit status.
- (A) is wrong: An orphan's parent has exited.
- (B) is wrong: No.
- (D) is wrong: It has finished.
Re-read: Lesson 1.1.2 — Creating processes with fork(), exec() and wait(); context switches and schedulers
Q3 Answer: 3.75 · 2 mark(s)
Idle 0–2; P1 2–6, P2 6–8; idle 8–10; P3 10–13, P4 13–14: TAT 4, 5, 3, 3.
Re-read: Lesson 2.1.1 — Scheduling basics: the times we measure; first-come first-served
Q4 Answer: 12 · 2 mark(s)
A 0–3, B 3–5, B 6–10 (back from I/O at 6), A 10–12.
Re-read: Lesson 2.2.2 — Multilevel queues, CPU and I/O bursts, CPU utilisation
Q5 Answer: (A) · 1 mark(s)
Spinning briefly beats a context switch.
- (B) is wrong: Spinning wastes the holder's CPU time.
- (C) is wrong: That is a blocking semaphore.
- (D) is wrong: A plain TSL lock doesn't give it.
Re-read: Lesson 3.1.3 — Hardware help: test-and-set, compare-and-swap, spinlocks
Q6 Answer: 6 · 2 mark(s)
Lose the decrement: P3's −1 is overwritten.
Re-read: Lesson 3.2.3 — Monitors, and reasoning about concurrent code
Q7 Answer: (B) · 1 mark(s)
Resources can now be pre-empted.
- (A) is wrong: Not directly.
- (C) is wrong: Still holding while waiting.
- (D) is wrong: Still exclusive.
Re-read: Lesson 4.1.2 — Prevention and avoidance: safe states and the banker's algorithm
Q8 Answer: 45768 · 2 mark(s)
p = 3, offset 712; 11 × 4096 + 712.
Re-read: Lesson 5.2.1 — Paging: pages, frames, page tables and the address split
Q9 Answer: 250 · 2 mark(s)
0.99998 × 150 + 2 × 10⁻⁵ × 5,000,000.
Re-read: Lesson 5.3.1 — Demand paging, page faults and effective access time
Q10 Answer: 9 · 2 mark(s)
1, 2, 3, 4 load; then 5, 1, 2, 3 and 4 each fault (the 2 right after 5 hits).
Re-read: Lesson 5.3.2 — Page replacement: FIFO, optimal and LRU; Belady's anomaly
Q11 Answer: 3 · 1 mark(s)
6 ms per rotation / 2.
Re-read: Lesson 6.2.1 — Disk structure and access time
Q12 Answer: 10 · 1 mark(s)
2000 × 50 µs = 0.1 s per second.
Re-read: Lesson 6.2.3 — I/O techniques: programmed I/O, interrupts, DMA, buffering and spooling