NivaarExam PrepOfficial exam papers ↗

25-Comp-A5 Operating Systems · Undated paper

Question 6 of 7: Disk-Scheduling Algorithms; Processes vs. Threads; Optimal CPU Scheduling

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

Notes on this paper

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.) — CPU scheduling (ch. 5), process synchronization/monitors (ch. 6–7), deadlocks (ch. 8), memory management/paging (ch. 9–10), mass-storage/file-system implementation and disk scheduling (ch. 11–12), protection (ch. 14); Tanenbaum, Modern Operating Systems (5th ed.), corroborating chapters on scheduling, synchronization, memory and file systems.

Question 6: Disk-Scheduling Algorithms; Processes vs. Threads; Optimal CPU Scheduling (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.

(a) Disk-arm scheduling: FIFO, SSTF, SCAN

Given. 180 tracks, numbered 0–179. The head is currently at track 141 and has just finished a request at track 130, so it is travelling in the increasing direction (130 → 141). Pending FIFO queue: 96, 157, 101, 176, 104, 160, 116, 174, 150. Head movement is measured from the current position, 141.

Find. Total head movement for (i) FIFO order, (ii) SSTF, (iii) SCAN.

Approach. (i) Service strictly in queue order, summing consecutive absolute differences. (ii) Always move to the closest pending request. (iii) SCAN continues in the current direction of travel (upward, since the head moved from 130 to 141) all the way to the physical end of the disk (track 179), servicing every request it passes, then reverses; on the return leg it travels only as far as the lowest remaining request, since nothing lies beyond it.

Track positions, 0-179 (head moving up: 130 -> 141)096101104116prev 130cur 141150157160174176179SCAN leg 1: 141 up to 179 (38)SCAN leg 2: 179 down to 96 (83)
Fig. Q6(a) — track positions on the 0–179 platter. SCAN sweeps up to track 179 first (the head is travelling upward, from 130 to 141), then reverses and descends only as far as the lowest pending request, 96.
  1. (i) FIFO — service in the given queue order. $141\to96\to157\to101\to176\to104\to160\to116\to174\to150$: $$45+61+56+75+72+56+44+58+24 = 491$$ $$\boxed{\text{FIFO total} = 491\text{ tracks}}$$
  2. (ii) SSTF — always serve the nearest pending request. From 141 the nearest request is 150 (9 away; 116 is 25 away), then 157 (7) → 160 (3) → 174 (14) → 176 (2); the nearest remaining is then 116 (60) → 104 (12) → 101 (3) → 96 (5). $$9+7+3+14+2+60+12+3+5 = 115$$ $$\boxed{\text{SSTF total} = 115\text{ tracks (order }150,157,160,174,176,116,104,101,96\text{)}}$$
  3. (iii) SCAN — continue up to the disk end, then reverse. Moving up from 141, the head services 150, 157, 160, 174, 176 on the way to track 179 (distance $179-141=38$); it then reverses and descends, servicing 116, 104, 101, 96, stopping at the lowest pending request, 96 (distance $179-96=83$). $$38+83=121$$ $$\boxed{\text{SCAN total} = 121\text{ tracks}}$$ For comparison, LOOK (reversing at 176 instead of the disk end) would give $35+80=115$, the same as SSTF here.
Final Results – Question 6(a)
AlgorithmTotal head movement (tracks)Service order
FIFO49196, 157, 101, 176, 104, 160, 116, 174, 150 (given order)
SSTF115150, 157, 160, 174, 176, 116, 104, 101, 96
SCAN121150, 157, 160, 174, 176, [179], 116, 104, 101, 96

(b) Multiple processes vs. multiple threads. Prefer threads when the concurrent tasks are logically part of one application and benefit from fast, low-overhead communication and shared state (shared address space means no IPC setup, cheaper creation/context-switch, and direct access to common data) — e.g. a GUI thread kept responsive while a worker thread computes. The cost is weak fault isolation: since all threads share one address space, a bug (bad pointer, stack overflow) in one thread can corrupt or crash the entire process. Prefer multiple processes when strong isolation, fault containment, or security boundaries matter more than communication speed — a crash in one process cannot directly corrupt another's memory (e.g. a browser's per-tab process model) — at the cost of higher creation/context-switch overhead and slower communication via IPC (pipes, shared-memory setup, message passing) instead of direct memory access. The choice is a trade-off between performance/shared-state convenience (threads) and robustness/isolation (processes), driven by how much the components need to trust each other.

(c) Why the optimal CPU scheduling strategy is hard to implement. For minimum average waiting (and turnaround) time the optimal strategy is Shortest-Job-First, or its preemptive form SRTF. It is hard to implement on a real system for several reasons:

Real systems therefore use approximations such as multilevel feedback queues, which infer burst behaviour from how processes used their previous time quanta.