NivaarExam PrepOfficial exam papers ↗

25-Comp-A5 Operating Systems · May 2015

Question 6 of 7: Variant Round-Robin Scheduling; Page-Reference LRU Trace

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)

Notes on this paper

98-COMP A-5 Operating Systems — National Examinations, May 2015. 3 hours, closed book (approved calculators only), 100 marks. Candidates were instructed to answer any five of the seven questions; all seven are answered below as a complete study resource.

Reference texts: Silberschatz, Galvin & Gagne, Operating System Concepts (10th ed.) — scheduling (ch. 5), process synchronization/monitors (ch. 6–7), deadlocks (ch. 8), memory management/paging (ch. 9–10), file systems and disk scheduling (ch. 11–12); Tanenbaum, Modern Operating Systems (5th ed.), corroborating chapters on scheduling and file systems.

Question 6: Variant Round-Robin Scheduling; Page-Reference LRU Trace (20 marks)

Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.

Given (a). Four single-burst, no-I/O processes; each process's own OWN time slice is fixed once from its total execution time (never adaptive during its run): <4 s → 2 s slice, 4–12 s (exclusive of 12) → 3 s slice, ≥12 s → 4 s slice.

Given data
ProcessArrival (s)Execution (s)Time slice (s)
Proc10164 (≥12)
Proc2283 (4–12)
Proc34184 (≥12)
Proc4622 (<4)

Find. The mean turnaround time across the four processes under this variant Round Robin.

Approach. Run a standard FIFO ready-queue Round Robin, but give each process its own fixed slice (from the table above) every time it is dispatched; a process whose remaining burst exceeds its own slice is preempted and re-queued at the back, one whose remaining burst is at most its slice runs to completion.

Check: the source does not state the tie-break convention for an instant at which a new arrival and a slice-expiry re-queue coincide (e.g. $t=4$s, where Proc3 arrives exactly as Proc1's first slice expires). This solution adopts the common convention that a same-instant new arrival is enqueued before the just-preempted process is put back at the tail — i.e., the arriving process gets in line ahead of the process being preempted at that same instant. The final mean would differ under the opposite convention.
Variant Round Robin schedule (total = 44 s)12314231231330471115172024283034384244
Fig. Q6(a) — Gantt chart of the variant Round Robin schedule. Digits label which process (1–4) occupies each time slice.
  1. Trace the queue. $t{=}0$: only Proc1 is present; it runs its 4 s slice, $0\to4$ (remaining $16-4=12$). At $t{=}4$, Proc3 arrives (enqueued first, per the stated convention) and Proc1 is re-queued behind it: queue order becomes Proc2, Proc3, Proc1 (Proc2 had already been waiting since $t{=}2$). Proc2 runs its 3 s slice, $4\to7$ (remaining $8-3=5$); Proc4 arrives at $t{=}6$ mid-slice and is enqueued the moment it arrives. At $t{=}7$ Proc2 is re-queued: order is Proc3, Proc1, Proc4, Proc2.
  2. Continue the round-robin cycle. Proc3 runs $7\to11$ (remaining $18-4=14$, re-queued). Proc1 runs $11\to15$ (remaining $12-4=8$, re-queued). Proc4 runs its 2 s slice $15\to17$ and, since its remaining burst was exactly 2 s, finishes at $t=17$ (no re-queue). Proc2 runs $17\to20$ (remaining $5-3=2$, re-queued). Proc3 runs $20\to24$ (remaining $14-4=10$, re-queued). Proc1 runs $24\to28$ (remaining $8-4=4$, re-queued). Proc2's remaining burst (2 s) is now under its own 3 s slice, so it runs to completion $28\to30$ and finishes at $t=30$.
  3. Finish the remaining two processes. Proc3 runs $30\to34$ (remaining $10-4=6$, re-queued). Proc1's remaining burst (4 s) exactly matches its slice; it runs $34\to38$ and finishes at $t=38$. Only Proc3 is left: it runs $38\to42$ (remaining $6-4=2$, re-queued to itself, since it is the only process left), then runs its final 2 s $42\to44$ and finishes at $t=44$. $$TT_{Proc1}=38-0=38,\quad TT_{Proc2}=30-2=28,\quad TT_{Proc3}=44-4=40,\quad TT_{Proc4}=17-6=11$$ $$\boxed{\overline{TT} = \dfrac{38+28+40+11}{4} = \dfrac{117}{4} = 29.25\ \text{s}}$$
Final Results — Question 6(a)
ProcessFinish timeTurnaround time
Proc138 s38 s
Proc230 s28 s
Proc344 s40 s
Proc417 s11 s
Mean turnaround time29.25 s

Given (b). Reference string of 20 accesses: 311,312,313,314,312,311,315,316,312,312,311,313,317,316,313,312,312,311,313,316; demand paging (a page loads only on first reference / fault); frames start empty.

Find. (i) The minimum possible page-fault count for this string under any replacement policy and any number of frames. (ii) The LRU fault count with exactly 3 frames.

Approach. (i) The absolute floor on page faults is set purely by how many distinct pages ever appear — each must fault at least once, on its first reference, and if there are at least that many frames available no page is ever evicted, so no page faults twice. (ii) Step through the string maintaining 3 frames, evicting the least-recently-used page on every fault.

  1. (i) Minimum possible faults. The distinct pages referenced are $\{311,312,313,314,315,316,317\}$ — seven distinct pages. Every page must fault the first time it is ever referenced (it cannot already be resident), so seven faults are unavoidable regardless of algorithm or frame count; with at least 7 frames allocated (enough to hold every distinct page simultaneously, so nothing is ever evicted), no page faults a second time. $$\boxed{\text{Minimum possible faults} = 7}$$
  2. (ii) LRU trace, 3 frames. Stepping through the string (full trace in the table below): the first three references (311, 312, 313) fault to fill the empty frames. Page 314 faults, evicting 311 (least recently used). Reference 312 hits; 311 faults again, evicting 313 (now LRU, since 312 and 314 were touched more recently). From there, 315 faults (evicts 314), 316 faults (evicts 312), 312 faults again (evicts 311), a hit on 312, then 311 faults (evicts 315), 313 faults (evicts 316), 317 faults (evicts 312), 316 faults (evicts 311), a hit on 313, 312 faults (evicts 317), a hit on 312, 311 faults (evicts 316), a hit on 313, and finally 316 faults once more (evicts 312). Counting every FAULT row in the trace table gives 15 faults. $$\boxed{\text{LRU faults (3 frames)} = 15}$$
LRU frame-by-frame trace (3 frames)
Ref #PageHit/FaultFrames after
1311Fault311
2312Fault311, 312
3313Fault311, 312, 313
4314Fault (evict 311)314, 312, 313
5312Hit314, 312, 313
6311Fault (evict 313)314, 312, 311
7315Fault (evict 314)315, 312, 311
8316Fault (evict 312)315, 316, 311
9312Fault (evict 311)315, 316, 312
10312Hit315, 316, 312
11311Fault (evict 315)311, 316, 312
12313Fault (evict 316)311, 313, 312
13317Fault (evict 312)311, 313, 317
14316Fault (evict 311)316, 313, 317
15313Hit316, 313, 317
16312Fault (evict 317)316, 313, 312
17312Hit316, 313, 312
18311Fault (evict 316)311, 313, 312
19313Hit311, 313, 312
20316Fault (evict 312)311, 313, 316
Final Results — Question 6(b)
MetricValue
Minimum possible faults (any policy, enough frames)7
LRU faults, 3 frames15