You are on page 1of 6

University of Haripur

2020
SHAHBAZ 28 May 2020
KHAN
F18-0312
BS(SE) 4th A

Submitted To : Ma’am Nighat Bibi


ASSIGNMENT # 2
Consider the following set of processes, with the length of CPU-burst
time given in milliseconds:

The processes are assumed to have arrived in the order p1, p2, p3, p4, p5
all at time 0.
a. Draw four Gantt Charts illustrating the execution of these
processes using FCFS, SJF, a non preemptive priority (a smaller
number implies higher priority, and RR (Quantum=1)
scheduling.
b. What is the turnaround time of each process for each of the
scheduling algorithms in part a?
c. What is the waiting time of each process for each of these
scheduling algorithms?
d. Which of the algorithms results in the minimum average waiting
time (over all processes)?

OPERATING SYSTEM UNIVERSITY OF HARIPUR


FIRST COME FIRST SERVED (FCFS)
Gantt Charts for execution of processes using FCFS

P1 P2 P3 P4 P5

0 10 11 13 14 19

Turnaround Time FCFS


P1 10
P2 11
P3 13
P4 14
P5 19

Waiting Time FCFS


P1 0
P2 10
P3 11
P4 13
P5 14

Average Waiting Time FCFS


(0+10+11+13+14) / 5 = 9.6
OPERATING SYSTEM UNIVERSITY OF HARIPUR
NON PREEMPTIVE PRIORITY
Gantt Charts for execution of processes

P2 P5 P1 P3 P4

0 1 6 16 18 19

Turnaround Time
P1 16
P2 1
P3 18
P4 19
P5 6

Waiting Time
P1 6
P2 0
P3 16
P4 18
P5 1

Average Waiting Time


(6+0+16+18+1) / 5 = 8.2

OPERATING SYSTEM UNIVERSITY OF HARIPUR


SHORTEST JOB FIRST ( SJF )
Gantt Charts for execution of processes

P2 P4 P3 P5 P1

1 2 4 9 19

Turnaround Time
P1 19
P2 1
P3 4
P4 2
P5 9

Waiting Time
P1 9
P2 0
P3 2
P4 1
P5 4

Average Waiting Time SJF Algorithm has shortest


average waiting time.
(9+0+2+1+4) / 5 = 3.2
OPERATING SYSTEM UNIVERSITY OF HARIPUR
ROUND ROBIN (RR)

Gantt Charts for execution of processes

p1 p2 p3 p4 p5 P1 P3 P5 P1 P5 P1 P5 P1 P5 P1 P1 P1 P1 P1

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Turnaround Time
P1 19
P2 2
P3 7
P4 4
P5 14

Waiting Time
P1 9
P2 1
P3 5
P4 3
P5 9

Average Waiting Time


(9+1+5+3+9) / 5 = 5.4

OPERATING SYSTEM UNIVERSITY OF HARIPUR

You might also like