Computer Sciences > GATE 2025 SET-2 > CPU Scheduling
Processes P1, P2, P3, P4 arrive in that order at times 0, 1, 2, and 8 milliseconds respectively, and have execution times of 10, 13, 6, and 9 milliseconds respectively. Shortest Remaining Time First (SRTF) algorithm is used as the CPU scheduling policy. Ignore context switching times.
Which ONE of the following correctly gives the average turnaround time of the four processes in milliseconds?
A
22
B
15
C
37
D
19

Correct : d

The correct answer is Option D — 19 milliseconds.
Let''s trace the SRTF Gantt chart step by step.
Given: P1(arrival=0, burst=10), P2(arrival=1, burst=13), P3(arrival=2, burst=6), P4(arrival=8, burst=9)
t=0: Only P1 available → P1 runs. Remaining: P1=9.
t=1: P2 arrives (burst=13). P1 remaining=9 < 13 → P1 continues.
t=2: P3 arrives (burst=6). P1 remaining=8, P3=6 → P3 preempts P1.
t=2 to t=8: P3 runs for 6ms → P3 completes at t=8.
t=8: P4 arrives (burst=9). Ready queue: P1(remaining=8), P2(remaining=13), P4(9). Shortest is P1(8) → P1 runs.
t=8 to t=16: P1 runs for 8ms → P1 completes at t=16... wait — P1 had 10 burst, ran 1ms before preemption, so remaining = 9 not 8. Let''s redo:
t=0 to t=1: P1 runs 1ms → remaining = 9
t=1 to t=2: P1 runs 1ms → remaining = 8
t=2: P3 arrives with burst=6 < P1 remaining=8 → P3 preempts.
t=2 to t=8: P3 runs → P3 completes at t=8. TAT(P3) = 8−2 = 6.
t=8: P4 arrives (burst=9). Ready: P1(rem=8), P2(rem=13), P4(9). Shortest = P1(8) → P1 runs.
t=8 to t=16: P1 runs → P1 completes at t=16... hmm but P4(9) and P1(8). P1 shorter → P1 runs till t=16. TAT(P1) = 16−0 = 16.
Wait — per the official Gantt chart on the page: P1(0-1), P3(1-8)... that means P3 preempts at t=1? But P3 arrives at t=2. The page shows P3(1-2) which is incorrect per arrival time. Using the correct data:
Correct Gantt: P1(0-2), P3(2-8), P1(8-16), P4(16-25), P2(25-38)... but that gives avg = (16+37+6+17)/4 = 76/4 = 19. ✓
Turnaround times:
P1: 16 − 0 = 16
P2: 38 − 1 = 37
P3: 8 − 2 = 6
P4: 25 − 8 = 17
Average = (16 + 37 + 6 + 17) / 4 = 76 / 4 = 19 ms

Similar Questions

Consider the following statements about process state transitions for a system using preemptive scheduling. I. A running process can move to ready state. II....
#288 MCQ
Which of the following CPU scheduling algorithm can potential cause starvation?
#802 MSQ
Consider a single processor system with four processes A, B, C, and D, represented as given below, where for each process the first value is its arrival time, a...
#925 MCQ

Related Topics

SRTF scheduling GATE 2025 GATE CS 2025 Set-2 Q26 shortest remaining time first average turnaround time SRTF CPU scheduling GATE Gantt chart SRTF preemptive SJF GATE P1 P2 P3 P4 scheduling turnaround time calculation operating system GATE 2025

Unique Visitor Count

Total Unique Visitors

Loading......