cs604 assignment 2 solution fall 2019

cs604 assignment 2 solution fall 2019

cs604 assignment 2 solution fall 2019

 

CS604: Operating Systems

Assignment 2 solution file

 

Question# 1:

Assume you have to apply Shortest Job First (SJF) scheduling algorithms on the set of different processes given in the table below. The CPU burst time is also given for each process. Consider that all the processes arrive in the ready queue within time 0 seconds except P2 that arrive in ready queue within time 8 seconds. You are required to show the Gantt Chart to illustrate the execution sequence of these processes and calculate the Total Waiting Time and Average Waiting Time for the given processes by using SJF algorithm.

 

 

Process CPU Burst Time (seconds)
P0 2
P1 6
P2 1
P3 4
P4 3
P5 8



Solution:

Process CPU Burst time

(seconds)

Arrival Time
P0 2 0
P1 6 0
P2 1 8
P3 4 0
P4 3 0
P5 8 0

 

 

GANTT CHART:

Consider that all the processes arrive in the ready queue within time 0 seconds except P2 that arrive in ready queue within time 8 seconds.

Waiting time = Starting time – Arrival time

Waiting time for P0= 0 – 0 = 0

Waiting time for P1= 10 – 0 = 10

Waiting time for P2= 9 – 8 = 1

Waiting time for P3= 5 – 0 = 5

Waiting time for P4= 2 – 0 = 2

Waiting time for P5= 16 – 0 = 16

Total Waiting Time = (P0 + P1 + P2 + P3 + P4 + P5 )= (0+10+1+5+2+16)= 34

Average Waiting time = Total Waiting Time / Total number of values

Average Waiting time = 34 / 6 = 5.66 seconds



Question# 2:

Consider a scenario where you have to apply Round Robin scheduling algorithm on the below given set of processes with each having a quantum size=8 milliseconds. The CPU burst time and arrival time for each process is also provided in the given table. You are required to show the Gantt Chart to illustrate the execution sequence of these processes. Moreover, calculate the Average Turnaround Time and Average Waiting Time for given processes by using round robin algorithm.

 

Process CPU Burst Time (Milliseconds) Arrival Time

(Milliseconds)

P0 15 0
P1 8 4
P2 25 18
P3 18 5

 

 

 

 

 

Solution:

A set of processes with each having a quantum size=8 milliseconds

 

Process CPU Burst  Time (Milliseconds) Arrival Time (Milliseconds) Remaining Time Remaining Time Remaining Time Remaining Time
P0 15 0 15 – 8 = 7 0 0 0
P1 8 4 8 – 8 = 0 0 0 0
P2 25 18 25 25 – 8 = 17 17 – 8 = 9 9 – 8 = 1
P3 18 5 18 – 8 =10 10 – 8 = 2 0 0

 

GANTT CHART:

 

 

Turnaround Time = Time A Process Terminate – Arrival Time

Turnaround Time for P0= 31 – 0 = 31

Turnaround Time for P1= 16 – 4 = 12

Turnaround Time for P2= 66 – 18 = 48

Turnaround Time for P0= 31 – 0 = 31

Turnaround Time forP3 = 57 – 5 = 52

Total Turnaround Time = P0 + P1  +P2 + P3 = 31 + 12 + 48 + 52 = 143

Average Turnaround Time = Total Turnaround Time /Total number of values

Average Turnaround Time = 143 / 4 = 35.75 Milliseconds

Waiting time = Turnaround Time – CPU Burst Time

Waiting time for P0= 31 – 15 = 16

Waiting time for P1= 12 – 8 = 4

Waiting time for P2= 48 – 25 = 23

Waiting time for P3= 52 – 18 = 34

Total Waiting Time = P0 + P1 + P2 + P3= 16 + 4 + 23 + 34 = 77

Average Waiting time = Total Waiting Time / Total number of values

Average Waiting time = 77 / 4 = 19.25 Milliseconds

 

 

 

 

 

 

 

Muhammad Reyan

Leave a Reply

%d bloggers like this: