Kingdom of Saudi Arabia Ministry of Higher Education Prince Sattam Bin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية وزارة التعليم العالي جامـعـة األمير سطام بن عبدالعزيز كلــيـــة هـنــدســـة وعلــــوم الحـاســب 2440 & 2544 :الشعبة Course Title: CS3701-Operating System CSC3701 Instructor Name: Mr. Abdul Haseeb Khan Tutorial Lecture # 06 CH: CPU Scheduling part-II Week# 06 Date: - - -2015 CPU Scheduling-Problem Solving Part: II Q Consider the following set of processes, with the length of CPU burst time given in milliseconds: Process P1 P2 P3 P4 i. Arrival Time 0 2 4 6 Burst Time 9 5 2 5 Draw the Gant charts illustrating the execution of these processes using non- preemptive SJF and preemptive SJF? Non- preemptive SJF: P1 P3 0 9 P2 11 P4 16 21 Preemptive SJF: P1 0 ii. iii. P2 2 P3 4 P2 6 P4 9 P1 14 21 What is the turnaround time of each process of the scheduling algorithms in part a? Non- preemptive SJF: P1= 9 , P2= 14 , P3= 7 , P4= 15 Preemptive SJF: 21 , P2= 7 , P3= 2 , P4= 8 P1= What is the waiting time of each process for each of the scheduling algorithms in part a? Non- preemptive SJF: P1= 0 , P2= 9 Preemptive SJF: P1= 12 , P2= 2 , P3= 5 , P3= 0 , P4= 10 , P4= 3 Round Robin Q: Given in the following table are four processes with order P1, P2, P3, and P4 with their arrival time and CPU burst times shown. Draw and Find the following CPU scheduling strategy is Round Robin with Quantum time: 2 i. ii. iii. Process Arrival Time Burst Time P1 1 9 P2 2 2 P3 3 1 P4 4 5 Draw the Gantt chart Round Robin Waiting time for each process and Average waiting time Turnaround time for each process and average turnaround time Round Robin Quantum time: 2 i. Gantt Chart: ii. Turn Around Time P1: 17 Average T.A.T: 8.5 iii. Waiting time P1: Average W.T: 4.25 P2: 8 P2: 1 3 P3: 3 P4: 11 P3: 2 P4: 6 Q: Consider the following set of processes, with the length of CPU burst time given in milliseconds: for round robin algorithm (quantum = 5) Process Burst Time P1 3 P2 7 P3 5 P4 2 P5 6 The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0. i. Draw the Gantt charts illustrating the execution of these processes using, RR scheduling. P1 P2 P3 P4 P5 P2 P5 0 3 8 13 15 20 22 23 ii. What is the turnaround time of each process? P1=3, P2= 22, P3=13, P4=15, P5=23 iii. What is the waiting time of each process? P1=3-3=0, P2=22-7= 15, P3=13-5=8, P4=15-2=13, P5=23-6=17 iv. What is the average waiting time (over all processes)? (0+15+8+13+17)/5=10.6 Q: Consider the following set of processes, with the length of the CPU-burst time given in milliseconds: Process Burst Time P1 3 P2 7 P3 5 P4 2 P5 6 The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0. a. Draw the Gantt charts using, RR (quantum = 5) scheduling. P1 b. c. d. P2 P3 P4 P5 P2 P5 3 8 13 15 20 22 23 What is the turnaround time of each process? P1=3, P2= 22, P3=13, P4=15, P5=23 What is the waiting time of each process? P1=3-3=0, P2=22-7= 15, P3=13-5=8, P4=15-2=13, P5=23-6=17 What is the average waiting time (over all processes)? (0+15+8+13+17)/5=10.6 iv. Q: Consider the following set of processes, with the length of the CPU-burst time given in milliseconds: Process Arrival Time Burst Time P1 0 4 P2 1 4 P3 4 3 P4 8 3 Draw the Gant charts illustrating the execution of these processes using FCFS and preemptive SJF? FCFS P1 P2 0 P3 4 P4 8 11 14 SJF: P1 P3 0 4 P2 7 P4 11 14 RR: P1 v. P2 P1 P2 P3 P1 P2 P3 P4 P4 P4 0 1 2 3 4 5 6 7 8 9 10 11 12 14 What is the turnaround time of each process of the scheduling algorithms in part a? 13 FCFS: P1= 4 , P2= 7 , P3= 7 , P4= 6 SJF: P1= 4 , P2= 10 , P3= 3 , P4= 6 RR: P1= 10 , P2= 10 , P3= 8 , P4= 6 P1 P2 P3 vi. What is the waiting time of each process for each of the scheduling algorithms in part a? FCFS: P1= 0 , P2= 3 , P3= 4 , P4= 3 SJF: P1= 0 , P2= 0 , P3= 6 , P4= 3 RR: P1= 6 , P2= 6 , P3= 5 , P4= 3 vii. Which of the schedules in part a results in the minimal average waiting time (over all processes)? FCFS Average waiting time= (0+3+4+3)/4 = 2.5 SJF Average waiting time= (0+0+6+3)/4 = 2.25 RR Average waiting time= (6+6+5+3)/4 = 5.0 SJF have minimal average waiting time.