in Operating System edited by
1,342 views
0 votes
0 votes

Lets consider one situation where,
OS is scheduling processes(P1,P2,P3...Pn) with Round Robin method and current running process is P1 and next scheduled process in queue is also P1 (this case is possible in Round Robin).

Will a context switch occur after the quantum time is over?
Provide reason behind your answer.

Supporting Question:

How many context switch will take place in Round Robin scheduling method with quantum=3unit for the given data below. AT=Arrival Time, BT=Burst Time

in Operating System edited by
1.3k views

9 Comments

@anupamsworld

The case you are explaining is like this situation that there is one process P1 whose burst time is 10 unit time and time quantum is 5 unit so after 5 unit of time the process will context switch or not ? 

am i correct ?

0
0
Absolutely correct, you are.
0
0
okay so for this case i belief no context switch occurs as we know context switch is a overhead and associated a cost with it so if i am operating system developer always try to minimize the cost .

say we can implement it by keeping a variable process_count in ready queue ,

so after completion of each time quantum we check

while(true)

{

if(process_count==1)

 run(one_time quantum);

--------remaining code--------

}

This is not the implementation but can be something like that so that for this case no context switch occurs.
0
0
Well, my given situation is similar to as if there is only one process. But, there could be multiple processes in queue and the given situation may arise.

In that case what will happen?
0
0

@anupamsworld can you specify the case?

0
0
the case is specified in the question only.
0
0

@Kabir5454
question is elaborated little more, please check.

0
0

@Kabir5454, yes context switch between same process, is implemention defined. 

1
1
Context switch would occur if there is another process in the ready queue waiting for the processor. Since there aren't any hence the dispatcher will not be invoked, in other words no context switch occurs .. imo.

As for the second part, there would be 11 context switches considering the dispatching of the 1st process as a context switch from a previous process. P2 will execute for 4 seconds hence it will require two time quanta but context switch should not happen. .. again imo.
0
0

1 Answer

1 vote
1 vote
11 context switches , context switch at 0 and at termination is not considered (default)

Related questions