CS FundamentalsVery hardGATE CS (PYQ pattern)

Four processes (arrival, burst) in ms: A (0, 7), B (1, 2), C (2, 1), D (2, 2). Scheduling is non-preemptive. Compare non-preemptive SJF (at each completion pick the shortest ARRIVED job; ties by arrival) with the best possible non-preemptive schedule, which may keep the CPU idle on purpose. What are the average waiting times (SJF, optimal)?

  1. A. 5.0 ms and 2.25 ms
  2. B. 5.0 ms and 5.0 ms
  3. C. 4.0 ms and 2.25 ms
  4. D. 5.0 ms and 1.5 ms

Correct answer: A. 5.0 ms and 2.25 ms

SJF must start A at 0 (nothing else has arrived), then C (7-8), B (8-10), D (10-12): waits 0, 5, 7, 8 = 20, average 5.0. Idling until t = 1 and running B, C, D, A starts them at 1, 3, 4, 6: waits 0, 1, 2, 6 = 9, average 2.25, the minimum over all orders. SJF is optimal only when all jobs are present at once; 1.5 ignores that B cannot start before t = 1.

More Operating Systems questions

Exams that ask this topic