1,622 views
1 votes
1 votes
Consider arrival time and execution time for the following process:-

P.id    A.T     B.T

1        2         5

2        7         9

3        8         3

4       10        4

 Assume, each context switch requires 1ms time (excluding first and last context switch).then solve it using SRTF(shortest remaining time first)

1 Answer

2 votes
2 votes
At time t=2 , Process 1 arrives (Since no time required for Context Switch) , it starts execution and completes execution at Time t = 7.

At time t=7 , Process 2 comes in and due to Context switch it takes 1ms to get into the Running state but at Time t= 8 , Process 3 comes in with less Burst time  so now there is Context switch before P2 starts executing(P2 couldn’t even execute for 1ms)  and Process 3 enters CPU at Time t = 9  (8 + 1 where 8 is Arrival Time and 1ms for Context switch)

At time t = 9 , Process 3 starts executing till time t= 10 when Process 4 arrives with Burst time 4ms. But since remaining Burst time of Process 3 (2ms) < Burst time of Process 4 < Burst time of Process 2 , there is no context switch and Process 3 continues execution .

At time t = 12 , Process 3 completes execution and there is Context switch , So Process 4 starts execution at time t = 13 .

At time t = 17 , Process 4 completes execution and there is a context switch . So Process 2 starts execution at time t = 18ms.

At time t = 27ms , Process 4 completes execution and since no time taken for Context switch for last process the Completion time is t = 27ms.

Related questions

1 votes
1 votes
1 answer
1
jayadev asked Oct 10, 2021
1,099 views
in round robin algorithm if a process with burst time = 10 arrived at t=0 and time quantum is 2 units, context switch time is 2 units . Then completion time of the proces...
1 votes
1 votes
1 answer
4
iarnav asked Jan 12, 2022
385 views
Does non preemptive CPU scheduling needs hardware support.kindly explain.