Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Notes on this paper
17-Comp-A5, Operating Systems — National Examinations, December 2019. 3-hour closed-book paper, 7 questions of 20 marks each (candidates asked to answer any 5; all 7 answered here). Total 100 marks.
Reference texts: Silberschatz, Galvin & Gagne, Operating System Concepts (10th ed., Wiley) — CPU scheduling (Ch.5), process synchronization (Ch.6–7), deadlocks (Ch.8), main memory (Ch.9), virtual memory (Ch.10), mass-storage/disk scheduling (Ch.11), file-system implementation/free-space management (Ch.12–14).
Data used below. (1) Q1(a): Proc3's execution time is 21 s (the printed column reads 14, 7, 21, 2, 1 for Proc1–5). (2) Q3(c): the base (relocation) register is 1500. (3) Q5(a) states that the disk has 160 tracks numbered 0 to 159, yet its request queue includes tracks 160, 174 and 176. This inconsistency in the paper is resolved by adopting a 200-track disk (0–199) for the C-SCAN calculation, the only sub-part affected. (4) Q6(b) lists the free holes as 305K/245K/405K/470K/270K/291K/325K/350K, but the next sentence restates the first two as 302K and 243K, a proofing slip in the paper; the full eight-value list is used throughout.
Given. Reference string of 20 accesses over 7 distinct pages {11,…,17}; base register = 1500, limit register = 1600.
Find. (a)(i)/(ii) the best- and worst-case fault counts achievable for any frame allocation; (b) the OPT fault count with exactly 3 frames; (c) physical address or addressing error for two logical addresses.
Approach. (i) the absolute floor on faults is one per distinct page (a page must be loaded the first time it is touched, however many frames exist); (ii) the absolute ceiling occurs with a single frame, which faults on every reference except an immediate repeat of the currently-resident page; (b) simulate Belady's optimal algorithm (evict the resident page whose next use is farthest in the future, or never reused) frame-by-frame; (c) an address is valid iff $0\le \text{logical}<\text{limit}$, and the physical address is then $\text{base}+\text{logical}$.
(a)(i) Minimum faults = number of distinct pages. The reference string touches pages $\{11,12,13,14,15,16,17\}$ — 7 distinct pages. With at least 7 frames available, every page faults exactly once (on first touch) and never again, so
$$\boxed{f_{\min}=7}$$
(a)(ii) Maximum faults = length of the string, provided no two consecutive references repeat. With a single frame, a reference faults unless it requests the page currently resident (i.e. the immediately preceding reference). Scanning all 19 consecutive pairs of the 20-long string shows no pair repeats (11-12, 12-13, 13-14, 14-12, …, 13-16 are all distinct pairs), so every single reference is a fault under 1 frame:
$$\boxed{f_{\max}=20}$$
(b) OPT with 3 frames — walk the string, evicting the resident page used farthest in the future. The first three distinct pages (11,12,13) fill the empty frames for free (3 faults). Each subsequent fault picks the resident page with no future use, or the largest next-use index, to evict.
OPT trace, 3 frames (F = fault)
Ref #
Page
Frames after
Fault?
Evicted (reason)
1
11
11,–,–
F
—
2
12
11,12,–
F
—
3
13
11,12,13
F
—
4
14
11,12,14
F
13 (next use furthest away, ref #12)
5
12
11,12,14
hit
—
6
11
11,12,14
hit
—
7
15
11,12,15
F
14 (never referenced again)
8
16
11,12,16
F
15 (never referenced again)
9–11
12,11,12
11,12,16
hit×3
—
12
13
12,13,16
F
11 (next use furthest away, ref #17)
13
17
13,16,17
F
12 (next use furthest away, ref #16)
14–15
16,13
13,16,17
hit×2
—
16
12
13,16,12
F
17 (never referenced again)
17
11
13,11,12
F
16 (next use furthest away, ref #20)
18–19
12,13
13,11,12
hit×2
—
20
16
16,11,12
F
13 (last reference — any resident page ties)
$$\boxed{f_{\text{OPT},3\text{ frames}}=11}$$
(c) Base/limit address translation. An address is valid iff $0\le L<\text{limit}=1600$; the physical address is then $\text{base}+L=1500+L$.
(i) $L=607$: $607<1600$, valid. $\text{PA}=1500+607=\boxed{2107}$.
(ii) $L=1702$: $1702\ge 1600$, outside the limit → addressing error / trap (segmentation fault) — no physical address is generated.