100% found this document useful (1 vote)
450 views

1 Case: FCFS (First Come First Served) : Process Burst Time

The document discusses different CPU scheduling algorithms: 1) FCFS - Calculates average waiting time of processes that arrive in order P1, P3, P2, P4. 2) FCFS with different process arrival times. 3) SJF non-preemptive - Calculates waiting times of processes with different burst times that arrive P2, P3, P4, P1, P5. 4) SJF preemptive - Shows how waiting times are calculated when shorter processes are prioritized and preemption is allowed. 5) Priority scheduling non-preemptive - Processes of different priorities that arrive at the same time and waiting times. 6

Uploaded by

Jamal Bouchbaben
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
450 views

1 Case: FCFS (First Come First Served) : Process Burst Time

The document discusses different CPU scheduling algorithms: 1) FCFS - Calculates average waiting time of processes that arrive in order P1, P3, P2, P4. 2) FCFS with different process arrival times. 3) SJF non-preemptive - Calculates waiting times of processes with different burst times that arrive P2, P3, P4, P1, P5. 4) SJF preemptive - Shows how waiting times are calculated when shorter processes are prioritized and preemption is allowed. 5) Priority scheduling non-preemptive - Processes of different priorities that arrive at the same time and waiting times. 6

Uploaded by

Jamal Bouchbaben
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

CPU Scheduling

1st Case : FCFS (First Come First Served)


Suppose that the processes arrive at time 0, in the order: P1 , P3 , P2 , P4
Draw Gantt Chart and calculate the average waiting time using the given table ??

Process Burst Time Waiting time :


P1 3 P1 = 0
P2 = 8
P2 9
P3 = 3
P3 5 P4 = 17
P4 7

P1 P3 P2 P4
0 3 8 17 24

Average waiting time = (0 + 8 + 3 + 17) / 4 = 7


2nd Case : FCFS (First Come First Served)
Draw Gantt Chart and calculate the average waiting time using the given table ??

Burst Arrival Waiting time : start time – arrival time


Process P1 = 0 – 0 = 0
Time Time
P2 = 24 – 3 = 21
P1 20 0
P3 = 20 – 2 = 18
P2 12 3 P4 = 36 – 5 = 31
P3 4 2
P4 9 5

P1 P3 P2 P4
0 20 24 36 45

Average waiting time = (0 + 21 + 18 + 31) / 4 = 70 / 4


3rd Case : SJF (short job first) non-Preemptive
Draw Gantt Chart and calculate the average waiting time using the given table ??

Burst Arrival Waiting time : start time – arrival time


Process P1 = 30 – 10 = 20
Time Time
P2 = 0 – 0 = 0
P2 12 0
P3 = 22 – 3 = 19
P3 8 3
P4 = 12 – 5 = 7
P4 4 5 P5 = 16 – 12 = 4
P1 10 10
P5 6 12

P2 P4 P5 P3 P1
0 12 16 22 30 40

Average waiting time = (20 + 0 + 19 + 7 + 4) / 5 = 50 / 5 = 10


4th Case : SJF (short job first) Preemptive
Draw Gantt Chart and calculate the average waiting time using the given table ??

Burst Arrival Waiting time : start time – arrival time


Process P1 = 30 – 10 = 20
Time Time
P2 = (0 – 0) + (21 - 3) = 18
P2 12 9 0
P3 = (3 – 3) + (9 - 5) = 4
P3 8 6 3
P4 = (5 – 5) = 0
P4 4 5 P5 = 15 – 12 = 3
P1 10 10
P5 6 12

P2 P3 P4 P3 P5 P2 P1
0 3 5 9 15 21 30 40

Average waiting time = (20 + 18 + 4 + 0 + 3) / 5 = 45 / 5 = 9


5th Case : Priority Scheduling non-Preemptive
Draw Gantt Chart and calculate the average waiting time using the given table ??

Burst Arrival Waiting time :


Process Priority start time – arrival time
Time Time
P1 10 3 All P1 = 6
P2 1 1 Processes P2 = 0
Arrived at P3 = 16
P3 2 4 The P4 = 18
P4 1 5 Same P5 = 1
P5 5 2 Time

P2 P5 P1 P3 P4
0 1 6 16 18 19

Average waiting time = (6 + 0 + 16 + 18 + 1) / 5 = 41 / 5 = 8.2


6th Case : Priority Scheduling Preemptive
Draw Gantt Chart and calculate the average waiting time using the given table ??

Burst Arrival Waiting time :


Process Priority start time – arrival time
Time Time
P1 10 9 7 3 0.0 P1 = (0 - 0)+(2 - 1)+(9 - 4) = 6
P2 1 1 1.0
P2 = 1 – 1 = 0
P3 = 16 – 2 = 14
P3 2 4 2.0
P4 = 18 – 3 = 15
P4 1 5 3.0 P5 = 4 – 4 = 0
P5 5 2 4.0

P1 P2 P1 P5 P1 P3 P4
0 1 2 4 9 16 18 19

Average waiting time = (6 + 0 + 14 + 15 + 0) / 5 = 35 / 5 = 7


7th Case : Round Robin (RR)
Draw Gantt Chart and Calculate The Average Waiting Time , where Quantum = 5 ms
Process Burst Time Waiting time :
P1 12 7 2 P1 = 0 + (24 - 5) + (37 - 29) = 27
P2 8 3 P2 = 5 + (29 - 10) = 24
P3 4
P3 = 10
P4 = 14 + (32 - 19) = 27
P4 10 5
P5 = 19
P5 5

P1 P2 P3 P4 P5 P1 P2 P4 P1

0 5 10 14 19 24 29 32 37 39

Average waiting time = (27 + 24 + 10 + 27 + 19) / 5 = 107 / 5 = 21.4


Thank You For Watching
. . Luck
Good
(

You might also like