NivaarExam PrepOfficial exam papers ↗

25-Comp-A5 Operating Systems · Undated paper

Question 1 of 7: CPU Scheduling — Generic Priority Formula & SRTF

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 1: CPU Scheduling — Generic Priority Formula & SRTF (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. Ready-queue priority = a·t; running priority = Q + b·t'; larger priority numbers run first; ties broken by earliest ready-queue entry time.

Find. (a) values of Q, a, b that reproduce FCFS. (b) SRTF described, with its benefits and shortcomings.

Approach. FCFS never lets waiting time or running time change who is selected — only arrival order matters — so the two rate parameters must be neutralized, leaving the explicit tie-break rule to do all the work.

  1. Freeze both priority formulas. Set $a=0$ and $b=0$. Then every process's ready-queue priority is $0\cdot t = 0$ for as long as it waits, and the running process's priority is $Q + 0\cdot t' = Q$ for as long as it runs — neither value ever changes with elapsed time.
  2. Confirm no process can ever jump the queue or get preempted. With every ready process permanently tied at priority $0$ (independent of how long each has waited), the "highest priority" rule can never distinguish between two ready processes on priority alone — it falls straight through to the explicit tie-break, earliest ready-queue entry time, which is exactly the FCFS ordering rule. The running process must also never be displaced by a newcomer, so its priority must not fall below the ready processes' value of $0$: $Q\ge 0$. With $Q=0$ the running process ties with every ready process, and the tie goes to the process that entered the ready queue first — the running process, which was itself chosen as the earliest entrant — so it is never preempted until it blocks or completes; with $Q>0$ it simply outranks them. A negative $Q$ would break FCFS: every ready process (priority $0$) would outrank the running process ($Q<0$) and preempt it at once.
  3. Verify against an independent FCFS reference simulator. A discrete-event simulator driven purely by these two formulas ($a=b=Q=0$) was compared against a plain arrival-order (FCFS) reference scheduler over five processes with staggered arrivals and different burst lengths, for $(Q,b)=(0,0)$, $(5,0)$ and $(2,1)$; each produced the FCFS completion order, while $Q=-1$ did not.
$$\boxed{a=0,\ \ b=0,\ \ Q=0\quad(\text{more generally } a=0,\ b\ge 0,\ Q\ge 0)}$$
Final Results – Question 1(a)
ParameterValueRole
a0ready-queue priority never ages → ties always broken by arrival order
b0 (any $b\ge0$)running priority never decays → running process is never overtaken while executing
Q0 (any $Q\ge0$)running priority never drops below a waiting process's 0 → no preemption; $Q<0$ would cause immediate preemption

(b) Shortest-Remaining-Time-First (SRTF). SRTF is the preemptive version of Shortest-Job-First: the scheduler always runs whichever ready process has the smallest remaining CPU burst, and whenever a new process arrives (or a burst estimate changes), if its remaining time is shorter than the currently running process's remaining time, the running process is preempted immediately in favour of the newcomer.

← Paper overview