Thursday , 21 November 2024

CS604 Assignment ni 4 Solution fall 2012

                                          Assignment no 4

a)

Let us consider that CPU remains idle for first 2 unit of time. Draw the Gantt chart and calculate the average turnaround time for above processes in this situation by using non preemptive Shortest Job First (SJF) scheduling strategy?

 

Solution:

 

 CPU Idle Process A Process C Process B


0                              2                              11                              13                         18

 

Process Arrival Time  End Time Burst Time  Turned around Time
A 1.0 11 9 10
B 1.4 18 5 16.6
C 2.0 13 2 11

 

Now,

                Average turnaround time = 10 + 16.6 + 11 / 3 = 12.5

 

 

 

 

b) Let us consider that CPU remains idle for first 1.5 unit of time. Draw the Gantt chart and calculate the average waiting time for above processes in this situation by using non preemptive Shortest Job First  (SJF) scheduling strategy?

 

Solution:

 

 

CPU Idle Process A Process C Process B


0                              1.5                          10.5                           12.5                    17.5

 

 

Process Arrival Time  F  Time Burst Time  Waiting Time
A 1.0 10.5 9 0.5
B 1.4 17.5 5 11.1
C 2.0 12.5 2 8.5

 

Now,

                Average waiting time = 0.5 + 11.1 + 8.5 / 3 = 6.7 Time units

 

c).Let us consider that CPU remains idle for first 1 unit of time and let us consider that a fourth process ‘D’ enters the system at time 3 and needs 1 unit of CPU time. Draw the Gantt chart and Calculate the average waiting time for four processes A, B, C and D in this situation by using preemptive SJF i.e. Shortest Remaining Time scheduling strategy.

 

Solution:

 

Process A Process B Process  C Process D Process C Process B Process A

1                          1.4                        2                           3                          4                           5                         9.4                       17

 

 

Process Arrival Time  F  Time Burst Time  Waiting Time
A 1.0 17 9 7
B 1.4 9.4 5 3
C 2.0 5 2 1
D 3.0 4 1 0

 

 


 

 

Now,

                Average waiting time = 7 + 3 + 1 + 0 / 4 = 2.75  unit Time

 

 

 

d.)Let us consider that CPU remains idle for first 3 unit of time. In this situation, draw the Gantt chart and calculate the average waiting time for a round robin algorithm with q (time quantum) set at 2. Ignore the effect of context switching time.

 

Solution:

 

                      Round Robin ( quantum Time = 2 )

PA PB PC PA PB PA PB PA PA

3                 5                  7                   9                11                 13                 15                 16               18             19

 

 

 

Process Arrival Time  End  Time Burst Time  T.T Waiting Time
A 1.0 19 9 18 9
B 1.4 16 5 14.6 9.6
C 2.0 9 2 5 3

 

 

 

Now,

                Average waiting time = 9 + 9.6 + 3 / 3 = 7.2 unit time

Check Also

CS604 Assignment no 02 Spring 2013

  Assignment No. 02 Total Marks:20 Due Date: Spring 2013 Tuesday 14th May CS604- Operating …

Leave a Reply

Your email address will not be published. Required fields are marked *

*