1. Consider the following set of processes, whit the length of the CPU- burst time given in milliseconds: Process Burst time (ms) Priority p1 p2 p3 p4 p5 10 (ms) 1 (ms) 2 (ms) 1 (ms) 5 (ms) 3 1 3 4 2 The processes are assumed to have arrived in the order p1, p2, p3, p4, p5, all at time 0. a-Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF a non-preemptive priority (a smaller priority number implies a higher priority), and RR (quantum =1 ) scheduling. b-What is the turnaround time of each process for each of the scheduling algorithms in part a? c-What is the waiting time of each process for each of the scheduling algorithms in part a? ANSWER 1. FCFS P1 p2 0 10 p3 11 p4 p5 13 14 19 2. SJF p2 0 p4 1 p3 2 p5 p1 4 9 19 3. Priority p2 0 p5 1 p1 6 p3 16 p4 18 19 4. RR p 1 0 p 2 1 p 3 2 p 4 3 p 5 4 p 1 5 p 3 6 1. Turnaround time for FCFS p1 p2 p3 p4 p5 = = = = = 10 11 13 14 19 ms ms ms ms ms 2. Turnaround time for SJF p1 p2 p3 p4 p5 = = = = = 19 1 4 2 9 ms ms ms ms ms 3. Turnaround time for priority p1 p2 p3 p4 p5 = = = = = 16 ms 1 ms 18 ms 19 ms 6 ms 4. Turnaround time for RR p1 p2 p3 p4 p5 = = = = = 19 2 7 4 14 ms ms ms ms ms p 5 7 p 1 8 p 5 9 p 1 10 p 5 11 p 1 12 p 5 13 p 1 14 p 1 15 p 1 16 p 1 17 p 1 18 19 1. Waiting time for FCFS p1 p2 p3 p4 p5 = = = = = 0 ms 10 ms 11 ms 13 ms 14 ms Average waiting time (FCFS ) = ( 0 + 10 + 11 + 13 + 14 ) / 5 = 9.6 ms 2. Waiting time for SJF p1 p2 p3 p4 p5 = = = = = 9 0 2 1 4 ms ms ms ms ms Average waiting time (SJF) = (9 + 0 + 2 + 1 + 4) / 5 = 3.2 ms 3. Waiting time for priority p1 p2 p3 p4 p5 = = = = = 6 0 16 18 1 ms ms ms ms ms Average waiting time ( priority ) = ( 6 + 0 + 16 + 18 + 1 ) / 5 = 8.2 ms 4. Waiting time for RR p1 p2 p3 p4 p5 = = = = = 14 - 5 = 9 1 6-1 = 5 3 13 - 4 = 9 ms ms ms ms ms Average waiting time ( RR ) = ( 9 + 1 + 5 + 3 + 9 ) / 5 = 5.4 ms Average waiting time; SJF = ( 9 +0+ 2+1+ 4 )/5 = 3.2 RR Priority = = 5.4 8.2 FCFS = ( 9 +1+ 5+3+ 9 )/5 = ( 6 + 0 + 16 + 18 + 1 ) = /5 ( 0 + 10 + 11 + 13 + 14 = )/5 is the min ms ms 9.6 ms