search
Log In
2 votes
518 views
Consider 4 processes sharing the CPU in round robin fashion. If context switch time is 1 sec , what must be the time quantum q such that the number of context switches are reduced , but at the same time each process is guaranteed to get the turn at the CPU for every 10 secs?

-------------------------------------------------------------------------

Ans 2 or 1.5 .

Is here any formula used like (n-1)q+ns

explain in detail
in Operating System 518 views
0
logically if we thought like this -

P1  |  P2  |  P3  |  P4  |  P1        (vertical lines denotes Context switches)

then before again P1 will be in running state, there will be 4 Context switches, hence 10-4 = 6 units of time is remaining,

To make full use of it, each process  P2, P3 AND P4 should run for 2 units of time. (i.e time quantum = 2)
0
if every one taking 2 unit of time

means 1 unit for process execution, and 1 unit for context switch

then 2 *4=8 unit utilized

how 10 unit utilized?
1
I'm saying between P1 and again P1, we have 10 units, there will be 4 context switches , so 10-4 = 6 units will be there.

Now in remaining 6 units if we gave process P2, P3, and P4 equally 2 units for running (this will be TQ) then overall 10 units are utilized.
1
ok, u mean time between P1 ended and P1 started

right?

U r not taking P1 time
0

IMO, the question lacks clarity, its slightly ambiguous.

 each process is guaranteed to get the turn at the CPU for every 10 secs?

Suppose process A executed at time 0ms, and now the current time is 10ms.

Then the question asks which of the following exactly? :-

  1. Before this very moment (i.e.10ms) the process A should have already been executed? OR
  2. At exactly this moment (i.e.10ms), Process A should be guaranteed to get started?

See this question :-

https://gateoverflow.in/1690/gate1998-2-17-ugcnet-dec2012-iii-43

1 Answer

2 votes
 
Best answer
$4$ processes given , Round Robin scheduling always use Circular queue data strucure.

So ordering will be  $P_1\rightarrow P_2 \rightarrow P_3 \ \rightarrow P_4\rightarrow P_1...$ till they exhaust their Burst time.

Now in question its mentioned that in b/w two scheduling on CPU , time should be $10\ sec.$

So considering that scenario would be $Q_1\ |CS \ |Q_2\ |CS \ |Q_3\ |CS\ |Q_4\ |CS\ |Q_1..$

$E_{qn}=3 \times Q \ + 4 \times CS=10$ sec

Given = $CS  \ = \ 1$sec

$\therefore Q=\color{RED}{2sec}$

selected by
0
yes, I was taking P1 time at first

Related questions

1 vote
1 answer
1
856 views
How many time context switch in Round Robin? ( if only one process remain in ready queue at end of scheduling does that count every time, when time slice over or only one time?)
asked Jan 7, 2017 in Operating System sanyam53 856 views
5 votes
3 answers
3
1.4k views
If we have only one process in ready queue with burst time "m", then how many context switching will happen using round robing scheduling with time quantum q ,where q<m.Assume that dispatching the process first time is not counted as a context switch.
asked Aug 26, 2017 in Operating System rahul sharma 5 1.4k views
0 votes
0 answers
4
390 views
What is the difference between context switch and preemption? In case of critical section between context switch and preemption which one is possible ? And if so happens then how does it save the system from data inconsistency?
asked Mar 30, 2018 in Operating System Akash Kumar Roy 390 views
...