GATE / CS ARCHIVE

GATE CSE 2017 SET 2 / QUESTION 51

GATE CSE 2017 Set 2 Q51

Operating Systems · CPU Scheduling · Full GATE CSE 2017 Set 2 paper

GATE 2017 Set 2, Q51 2 marks · NAT
Report issue

CPU Scheduling

Question 51, GATE 2017: Processes have (arrival time,CPU burst,priority), all times in ms: P1:(0,11,2), P2:(5,28,0), P3:(12,2,3), P4:(2,10,1), P5:(9,16,4). Priority 0 is highest, there are no I/O bursts, and scheduling is preemptive priority with zero unspecified switching overhead. Find average waiting time.
Tap to enlarge
Answer & solution

Official answer: 29.0

Our answer: 29

Step through it (10 steps)

1. P1 starts at 0. At 2, higher-priority P4 arrives and preempts it; P1 has 9 ms left. At 5, highest-priority P2 arrives and preempts P4, which has 7 ms left. P2 runs uninterrupted to 33; later arrivals P5 and P3 have lower priorities.

2. Among waiting processes, run P4 from 33–40, P1 from 40–49, P3 from 49–51, then P5 from 51–67. Completion times are C1=49,C2=33,C3=51,C4=40,C5=67.

3. With no I/O, waiting time equals completion minus arrival minus CPU burst. Thus W1=49-0-11=38; W2=33-5-28=0; W3=51-12-2=37; W4=40-2-10=28; W5=67-9-16=42. The total is 145, so the average is 145/5=29 ms. Do not confuse waiting time with turnaround, which also includes execution.

Original paper, page 21 · Answer key