in Operating System
5,901 views
2 votes
2 votes

Consider the processes P1, P2, P3, P4 whose arrival times are 0, 1, 2, 3 and Burst times are 5, 2, 13, 7. If the Context Switching time is 1 unit (ms), what is the average waiting time if Shortest Job Next scheduling algorithm is used?

(a) 7.5
(b) 6.25
(c) 6.5
(d) None

(The Doubt i am facing here is , would we be covering the context switching time in the starting ?)

in Operating System
by
5.9k views

12 Comments

edited by
@joshi_nitish @Shubhanshu @Rupendra+Choudhary

What do you think? Should we consider context switch time in starting?

I think we should not consider it?
0
0
@Shivam Chauhan
Is there any Criteria on which we decide that starting context switching time should be taken or not ?
Because in some questions we take & in others we don't.
0
0
In the starting only one process is executing so there is no context overhead on that process.

So should not consider cs time in starting.
0
0

@santhoshdevulapally
I didn't get what you trying to explain.
(In the Starting only One Process is Executing ?)
[In This Question at 0th time we have P1 ,So to Execute it would we be doing context Switch or not ?]
Pls. Elaborate

0
0
@yogi_p

Other than round robin scheduling if only one process is present in the system at that time then system considered it is not context overhead.

So in the above problem at time 0 ,P1 is only active then how context switch takes place ?

What I want to tell u is if only one process there is no context switching time in all algorithms except RR.
0
0
we do not consider context switching time at start.
0
0

@santhoshdevulapally
Okay 
But if Arrival time of all the processes would have been 0, Then context switching would be there.
Right ? 

0
0
yogi_p

Bhai refer once what is context switching and context overhead .Then all your doubts are clear.
0
0
@santhoshdevulapally
Can you send me some good link ?
0
0
But when the very first process execute then its state changes from ready state to running state, and state need to be saved in context switch only. So why not first is a context switch?
0
0
what is the ans then ...???
0
0
i am getting answer as 7 but the key is 6.5. Can anyone conform?
0
0

3 Answers

3 votes
3 votes

Process Id      Arrival time     Burst time   Exit time  Wait time

P1                     0                           5                       5                   0

P2                     1                           2                       8                   5

P3                     2                          13                     30                 15

P4                     3                           7                      16                  6 

Wait time=Exit time-Burst time-Arrival time

Gantt chart:-

P1 1ms P2 1ms P4 1ms P3

0               5       6         8       9                    16    17                          30

 

Average wait time=(0+5+15+6)/4   = 26/4  = 6.5ms

2 votes
2 votes
(4+1+16+7)/4=7
0 votes
0 votes
in starting there is only one process is in execution , so there is no context switching in starting .
by

Related questions