CPU Scheduling 1 st Case FCFS First Come

  • Slides: 8
Download presentation
CPU Scheduling 1 st Case : FCFS (First Come First Served) Suppose that the

CPU Scheduling 1 st Case : FCFS (First Come First Served) Suppose that the processes arrive at time 0, in the order: P 1 , P 3 , P 2 , P 4 Draw Gantt Chart and calculate the average waiting time using the given table ? ? Process Burst Time P 1 3 P 2 9 P 3 5 P 4 7 P 1 0 P 4 P 2 P 3 3 Waiting time : P 1 = 0 P 2 = 8 P 3 = 3 P 4 = 17 8 17 Average waiting time = (0 + 8 + 3 + 17) / 4 = 7 24

2 nd Case : FCFS (First Come First Served) Draw Gantt Chart and calculate

2 nd Case : FCFS (First Come First Served) Draw Gantt Chart and calculate the average waiting time using the given table ? ? Process Burst Time Arrival Time P 1 20 0 P 2 12 3 P 3 4 2 P 4 9 5 P 1 0 P 3 20 24 Waiting time : start time – arrival time P 1 = 0 – 0 = 0 P 2 = 24 – 3 = 21 P 3 = 20 – 2 = 18 P 4 = 36 – 5 = 31 P 2 P 4 36 Average waiting time = (0 + 21 + 18 + 31) / 4 = 70 / 4 45

3 rd Case : SJF (short job first) non-Preemptive Draw Gantt Chart and calculate

3 rd Case : SJF (short job first) non-Preemptive Draw Gantt Chart and calculate the average waiting time using the given table ? ? Process Burst Time Arrival Time P 2 12 0 P 3 8 3 P 4 4 5 P 1 10 10 P 5 6 12 P 2 0 P 4 12 Waiting time : start time – arrival time P 1 = 30 – 10 = 20 P 2 = 0 – 0 = 0 P 3 = 22 – 3 = 19 P 4 = 12 – 5 = 7 P 5 = 16 – 12 = 4 P 5 16 P 3 22 P 1 30 Average waiting time = (20 + 19 + 7 + 4) / 5 = 50 / 5 = 10 40

4 th Case : SJF (short job first) Preemptive Draw Gantt Chart and calculate

4 th Case : SJF (short job first) Preemptive Draw Gantt Chart and calculate the average waiting time using the given table ? ? Burst Time Process P 2 12 9 0 P 3 8 6 3 P 4 4 5 P 1 10 10 P 5 6 12 P 2 0 Arrival Time P 3 3 P 4 5 Waiting time : start time – arrival time P 1 = 30 – 10 = 20 P 2 = (0 – 0) + (21 - 3) = 18 P 3 = (3 – 3) + (9 - 5) = 4 P 4 = (5 – 5) = 0 P 5 = 15 – 12 = 3 P 3 9 P 5 15 P 1 P 2 21 30 Average waiting time = (20 + 18 + 4 + 0 + 3) / 5 = 45 / 5 = 9 40

5 th Case : Priority Scheduling non-Preemptive Draw Gantt Chart and calculate the average

5 th Case : Priority Scheduling non-Preemptive Draw Gantt Chart and calculate the average waiting time using the given table ? ? Process Burst Time Priority P 1 10 3 P 2 1 1 P 3 2 4 P 4 1 5 P 5 5 2 P 2 0 P 5 1 Arrival Time Waiting time : start time – arrival time All Processes Arrived at The Same Time P 1 = 6 P 2 = 0 P 3 = 16 P 4 = 18 P 5 = 1 P 1 6 P 3 16 Average waiting time = (6 + 0 + 16 + 18 + 1) / 5 = 41 / 5 = 8. 2 P 4 18 19

6 th Case : Priority Scheduling Preemptive Draw Gantt Chart and calculate the average

6 th Case : Priority Scheduling Preemptive Draw Gantt Chart and calculate the average waiting time using the given table ? ? Burst Time Process P 1 0 Priority Arrival Time 3 0. 0 1 1. 0 P 2 10 9 1 P 3 2 4 2. 0 P 4 1 5 3. 0 P 5 5 2 4. 0 P 1 P 2 P 1 P 5 1 2 7 4 Waiting time : start time – arrival time P 1 = (0 - 0)+(2 - 1)+(9 - 4) = 6 P 2 = 1 – 1 = 0 P 3 = 16 – 2 = 14 P 4 = 18 – 3 = 15 P 5 = 4 – 4 = 0 P 1 9 P 4 P 3 16 Average waiting time = (6 + 0 + 14 + 15 + 0) / 5 = 35 / 5 = 7 18 19

7 th Case : Round Robin (RR) Draw Gantt Chart and Calculate The Average

7 th Case : Round Robin (RR) Draw Gantt Chart and Calculate The Average Waiting Time , where Quantum Process P 1 12 7 P 2 8 P 3 4 P 4 10 5 P 5 5 P 1 0 Burst Time P 2 5 P 3 10 Waiting time : 2 P 1 = 0 + (24 - 5) + (37 - 29) = 27 P 2 = 5 + (29 - 10) = 24 P 3 = 10 P 4 = 14 + (32 - 19) = 27 P 5 = 19 3 P 4 14 = 5 ms P 5 19 P 1 24 P 2 29 P 4 32 P 1 37 39 Average waiting time = (27 + 24 + 10 + 27 + 19) / 5 = 107 / 5 = 21. 4

Thank You For Watching ( . . Luck Good

Thank You For Watching ( . . Luck Good