retagged by
920 views
0 votes
0 votes
I have a doubt regarding the no of context switches needed in any scheduling algorithm. assume we have 5 processes, which require 4, 6, 7,5 and 1 time units and arrive at times 0, 1, 2,3, and 5
respectively. How many context switches are needed if
the operating system implements shortest remaining. here if we are doing this firstly we will run |p1| p1| p4| p5| p4| p2|

                                                                                                                                                        0  1   4   5   6   10 16  23 so total no of context switches are 7 but in solution the run p1 directly 0 to 4 I wanted to ask how SRTF work internally (as i know it will check firstly for next process arrival time then it will go ahed)
retagged by

1 Answer

1 votes
1 votes

P5 takes minimum time but it's arrival time is 5 sec..

In case of SRTF ->

0             4                5             6              10          16         23

     P1            P4            P5          P4          P2         P3    

Here also first P1 execute and then P4 BUT P4 Preempted on 5th sec (Execute only one unit of time 4 unit of time left) bcs on 5th sec Process P5(1sec) active and it take CPU. And P1 first execute and then P4 execute its remaining 4 sec bcs its lesser then time taken by P2 and P3. 

Hope i make it simple. Thanks

 

Related questions

0 votes
0 votes
2 answers
2
tusharb asked Apr 6, 2022
571 views
Suppose we have priority-based processes. Which scheduler will replace a low priority process which is presently executing when a high priority process arrives in the rea...
1 votes
1 votes
1 answer
3
atulcse asked Nov 4, 2021
1,004 views
Does FCFS suffer from starvation?
0 votes
0 votes
3 answers
4
manisha11 asked May 7, 2019
1,268 views
In Multi-processing Operating Systems:(a) Maximum utilization of CPU can be achieved(b) Maximum throughput is achieved(c) Maximum security can be achieved(d) Not suitable...