GATE / CS ARCHIVE

GATE CSE 2020 / QUESTION 50

GATE CSE 2020 Q50

Operating Systems · CPU Scheduling · Full GATE CSE 2020 paper

GATE 2020, Q50 2 marks · NAT
Report issue

CPU Scheduling

Question 50, GATE 2020: All processes arrive at time 0. Burst times: P1=8,P2=7,P3=2,P4=4 ms. Compare SJF with RR, quantum 4 ms and initial order P1,P2,P3,P4. Find the absolute difference in average turnaround times, to two decimal places.
Tap to enlarge
Answer & solution

Official answer: 5.25

Step through it (2 schedules)

Worked explanation

Turnaround time is completion minus arrival, not just waiting time. With all arrivals zero, completion times can be averaged directly. SJF Gantt timeline: 0—P3—2—P4—6—P2—13—P1—21. RR timeline: 0—P1—4—P2—8—P3—10—P4—14—P1—18—P2—21. After their first slices P1 has 4 ms remaining and P2 has 3; P3 and P4 finish in their first slices and leave the queue. In process order P1,P2,P3,P4, completions are (21,13,2,6) for SJF and (18,21,10,14) for RR. Sums 42 and 63 divided by 4 give the required difference 5.25 ms.

Derivation and answer

SJF executes P3, P4, P2, P1, completing them at 2, 6, 13, 21ms. Since arrivals are all zero, average turnaround is 42/4=10.5ms. RR with quantum 4 executes P1[0, 4], P2[4, 8], P3[8, 10], P4[10, 14], P1[14, 18], P2[18, 21]. Completion times are 18, 21, 10, 14ms, averaging 63/4=15.75ms. The absolute difference is 15.75−10.5=5.25ms, with zero context-switch overhead as conventionally assumed.

Original paper, page 15 · Answer key