849 views
0 votes
0 votes

Consider three processes, P1, P2, and P3. Their start times and execution
times are given below

Let x be the amount of time taken by the kernel to complete a context
switch from any process Pi to Pj . For what values of x will the average
turnaround time for P1, P2, P3 be reduced by choosing a Shortest Remaining
Time First scheduling policy over a Shortest Job First policy?

3 Answers

4 votes
4 votes

In case of SJF

P.No AT BT CT TAT WT
1 0 100 100 100 0
2 25 50 170 145 45
3 50 20 120 70 50

0                                        100                                    120                                   170

p2 p3 p2

Avg TAT =100+145+70 /3 =105

In case of SRTF

P no AT BT CT TAT WT
1 0 100 170 170 70
2 25 50 95 70 20
3 50 20 70 20 0

0                       25                     50                      70                     95                      170

p1 p2 p3 p2 p1

Avg TAT =170+70+20 /3 =86.66

They asked For what values of x will the average
turnaround time for P1, P2, P3 be reduced by choosing a SRTF over SJF  But here it is already less so we can consider x=0. (See both TAT         ( SRTF  TAT<SJF TAT))



0 votes
0 votes
0-------P1-------------100----------P3-----------120------------P2---------------170

Avg. turn around time for P1,P2,P3 using SJF=(100-0)+(120-50)+(170-25)=315/3=105

 

0---------P1----------25------P2----------50-----------P3---------70----------P2----------95-----------P1-------------170

Avg. turn around time for P1,P2,P3 using SRTF=(170-0)+(95-25)+(70-50)=260/3 = 86.66

So, it will not depend on context switch time

So, we can put x is 0 or any positive value , but here turnaround time for P1, P2, P3  Shortest Remaining
Time First scheduling policy will be less than Shortest Job First policy
edited by
0 votes
0 votes
since there are more number of context switch in case of shortest remaining time first compared to shortest job first, so ,you have to find highest value of x (or range of x)....

for finding highest value of x, take TAT of srtf equal to sjf . and calculate x....

Related questions

2 votes
2 votes
0 answers
2