loading...

CS604 Assignment 1 Solution Spring 2018

 

Assignment                                                                                                                              Marks 20    

Problem Statement

Consider the following four processes which enter the ready queue according to following time.

Processes Arrival time CPU Burst
P1 0 9
P2 3 6
P3 5 3
P4 6 2

a)      You are required to provide the Gantt chart for non-preemptive SJF (Shortest Job First) scheduling algorithm. Calculate the waiting time for each process and average waiting time.

b)      You are required to provide the Gantt chart for preemptive SJF (Shortest Job First) or STRF (Shortest Remaining Time First) scheduling algorithm. Calculate the waiting time for each process and average waiting time.

c)      From the above calculations, you have to mention the name of scheduling algorithm which performs better in term of average waiting time.

 

Solution:

  1. Non-preemptive SJF Gantt chart:

  

0                          9           11           14                     20

 

 

Processes

 

Waiting Time

 

P1

 

0

P2    11
P3    6
   P4     3
P1   P4  P3    P2

Average Waiting Time = (0+11+6+3) / 4 = 20/4 = 5

  1. b) Preemptive SJF
 

Processes

 

Waiting Time

 

P1

 

5

P2      11
P3       0
P4       2
Average Waiting Time =   (5+11+0+2) / 4 = 18 / 4

=4.5

Gantt chart:

  P1  P3  P4  P1  P2

0           5           8      10         14             20

  1. c) Preemptive SJF scheduling algorithm performs better in term of average waiting time
DOWNLOAD SOLUTION HERE
loading...