NivaarExam PrepOfficial exam papers ↗

25-Comp-A5 Operating Systems · December 2019

Question 6 of 7

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.

Question 6 (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) Degree of multiprogramming vs. CPU/paging-disk utilization. The governing intuition (Silberschatz's CPU-utilization curve against degree of multiprogramming) is: as long as the paging device is not the bottleneck, adding more ready processes gives the scheduler more choice and raises CPU utilization; but once the paging disk is nearly saturated, the system is thrashing — processes spend almost all their time waiting on page faults rather than computing — and adding more processes only demands more page-in/out traffic, driving CPU utilization down further, not up.

Check: the source's free-list sentence restates the first two holes as "302K"/"243K", which does not match its own fully-enumerated list of 305K/245K/…/350K given one paragraph earlier. We use the fully-enumerated 8-value list as authoritative.

Given. Free list, in order: 305K, 245K, 405K, 470K, 270K, 291K, 325K, 350K. Jobs arrive in order: 322K, 305K, 403K, 290K.

Find. Which hole each job is allocated to, under (i) best fit and (ii) first fit, updating the free list after each allocation (remainder of a partially-used hole becomes a new smaller hole in the same slot).

Approach. Best fit scans all current holes and picks the smallest one still $\ge$ the request; first fit scans the list from the start and picks the first hole $\ge$ the request. Both leave any unused remainder behind as a (possibly tiny) new hole.

  1. (i) Best fit. Job 1 (322K): smallest hole $\ge322$K among {305,245,405,470,270,291,325,350} is 325K — allocated, leaving a 3K remainder. Job 2 (305K): smallest hole $\ge305$K is 305K itself — an exact fit, hole fully consumed. Job 3 (403K): smallest hole $\ge403$K among the survivors {245,405,470,270,291,3,350} is 405K — leaving a 2K remainder. Job 4 (290K): smallest hole $\ge290$K among {245,2,470,270,291,3,350} is 291K — leaving a 1K remainder.
  2. (ii) First fit. Job 1 (322K): scanning from the start, 305K and 245K are too small; the first hole $\ge322$K is 405K — leaving an 83K remainder. Job 2 (305K): scanning from the start, the first hole $\ge305$K is 305K itself — exact fit. Job 3 (403K): scanning from the start, 245K/83K(remainder) are too small; the first hole $\ge403$K is 470K — leaving a 67K remainder. Job 4 (290K): scanning from the start, 245/67/270 are too small; the first hole $\ge290$K is 291K — leaving a 1K remainder.
Final Results – Question 6(b)
JobBest fit — hole usedFirst fit — hole used
Job 1 (322K)325K hole (3K remainder)405K hole (83K remainder)
Job 2 (305K)305K hole (exact fit)305K hole (exact fit)
Job 3 (403K)405K hole (2K remainder)470K hole (67K remainder)
Job 4 (290K)291K hole (1K remainder)291K hole (1K remainder)

Best fit wastes far less space per allocation here (3K/0/2K/1K vs. first fit's 83K/0/67K/1K) but at the cost of scanning every hole on every allocation, and it tends to litter memory with many tiny unusable slivers (external fragmentation) exactly like the 3K/2K/1K remnants above.