Scheduling Algorithms: 1. Fcfs

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

Scheduling Algorithms

Waiting time = how much time it waited to for CPU (depend on algo)
Turnaround time=waiting time + burst time
Departure time= Arrival time + turnaround time
1. FCFS

Process Arrival Burst Departure Turnaround Waiting time


time time(CPU) Time time

P1 0 24 24 24 0
P2 0 3 27 27 24
P3 0 3 30 30 27
Average waiting time (0+24+27)/3=17ms
P1- p2 –p3
Gantt Chart
P1 P2 P3
0 24 27 30
2.SJF
Proces Arriva Burst Depar Turnaroun Waiting time
s l Time time ture d time
Time
P1 0 6 9 9 3
P2 0 8 24 24 16
P3 0 7 16 16 9
P4 0 3 3 3 0
Average waiting time (3+16+9+0)/4=7ms
Gantt Chart

P4 P1 P3 P2
0 3 9 16 24

FCF= 10.25ms
3. Shortest Remaining Time next

Process Arrival Burst Departure Turnaround Waiting


Time time Time time time
P1 0 8 17 17 9
P2 1 4 5 4 0
P3 2 9 26 24 15
P4 3 5 10 7 2
Average waiting time 6.5ms

Average waiting time: ((10-1)+(1-1)+(17-2)+(5-3))/4 =


6.5

With SJF: (0+4+(4+5)+(4+5+8))/4 = 7.75


Gantt Chart

P1 P2 P4 P1 P3
0 1 5 10 17 26
Process Arrival time Burst time(CPU) Turnaround time Waiting time

P1 0 24 30 6(10-4)
P2 0 3 7 4
P3 0 3 10 7
4+7+6=17/3
Round Robin (Quantum- 4 Units)

Average waiting time: (0+4+7+(10-4))/3 = 5.66

P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30

Priority scheduling

Process Arrival Burst Prority Turnaround Waiting


time time(CPU) time time
P1 0 10 3 6

P2 0 1 1 0
P3 0 2 4 16
P4 0 1 5 18
P5 0 5 2 1
Av waiting Time =(6+ 16+ 18+1)/5=8.2
P2 P5 P1 P3 P4
0 1 6 16 18 19
Assignment1
Exercise:
1. Calculate the Departure time, Turnaround time, waiting time &average
waiting time for FCFS. SJR. . Shortest Remaining time next, & round
Robin ( 2 units ) .
Draw the Gantt chart also.
Process Arrival Burst
time time(CPU)

P1 2 4
P2 4 6
P3 5 3

2. Find the calculate the Departure time, Turnaround time waiting time
&average waiting, for FCFS. SJF. Shortest Remaining time next, & round Robin (
2 units ) Scheduling Algorithms for the following example

Process Arrival Burst


time time(CPU)

P1 0 5
P2 2 8
P3 3 1
P4 11 4
P5 12 2

You might also like