Three CPU-bound tasks, with execution times of 15, 12 and 5 time units respectively arrive at times 0, t and 8, respectively. If the operating system implements a shortest remaining time first scheduling algorithm, what should be the value of t to have 4 context switches? Ignore the context switches at time 0 and at the end.

Three CPU-bound tasks, with execution times of 15, 12 and 5 time units respectively arrive at times 0, t and 8, respectively. If the operating system implements a shortest remaining time first scheduling algorithm, what should be the value of t to have 4 context switches? Ignore the context switches at time 0 and at the end. Correct Answer 0 < t < 3

Process scheduling Algorithm: shortest remaining time first scheduling

Process Table:

Process

Arrival Time

Burst Time

P0

0

15

P1

t

12

P2

8

5

 

Gantt Chart:

At t = 0:

P1

P1

P2

P0

0           8            12          17          32

                           1st              2nd 

2 context switches occur. Hence Option 2  and 3 is eliminated.

At t = 1:

P0

P1

P2

P1

P0

0           1            8           13           18         32

              1st        2nd         3rd          4th   

4 context switches occur.

Since P2 and P1 has the same burst time we can choose any process at t = 8

At t = 2:

P0

P1

P2

P1

P0

0           2            8           13           19          32

             1st         2nd         3rd          4th  

4 context switches occur.

At = 5:

P0

P0

P2

P0

P1

0           5            8           13           20          32

                           1st         2nd          3rd  

Only 3 context switches occur. Hence Option 4 is also eliminated.

Therefore, option 1 is the correct answer

Related Questions