Develop a Gantt Chart, Average Waiting time, FCFS, SJF, RR

RGPV 2020 CPU Scheduling Algorithm

Consider the following set of processes.

Process

Burst Time

Arrival Time

P1

3

0

P2

5

1

P3

2

2

P4

5

3

P5

5

4


Develop a Gantt-chart and calculate the average waiting time using:
i) FCFS
ii) SJF
iii) Round Robin (q = 1)

Solution:

i) FCFS

Gantt Chart for FCFS

From above Gantt Chart waiting time for each process:

Waiting time = Turnaround time - Burst time

Process

Waiting time

P1

3-3=0

P2

7-5=2

P3

8-2=6

P4

12-5=7

P5

16-5=11


Average waiting time = Sum of waiting time / Number of processes

Average waiting time = (0+2+6+7+11)/5 = 5.2



ii) SJF

Gantt Chart SJF

From above Gantt Chart waiting time for each process:

Waiting time = Turnaround time - Burst time

Process 

Waiting time 

P1 

3-3=0 

P2 

9-5=4 

P3 

3-2=1 

P4 

12-5=7 

P5 

16-5=11 


Average waiting time = Sum of waiting time / Number of processes

Average waiting time = (0+4+1+7+11)/5 = 4.6



iii) Round Robin (q = 1)

Gantt Chart RR


From above Gantt Chart waiting time for each process:

Waiting time = Turnaround time - Burst time

Process 

Waiting time 

P1 

11-3=8 

P2 

17-5=12 

P3 

6-2=4 

P4 

16-5=11 

P5 

16-5=11 


Average waiting time = Sum of waiting time / Number of processes

Average waiting time = (8+12+4+11+11)/5 = 9.2
Share:

Post a Comment

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.