The Gateway to Computer Science Excellence
+2 votes
331 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 by Veteran (118k points) | 331 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}$
by Boss (11.9k points)
selected by
0
yes, I was taking P1 time at first

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,258 answers
198,086 comments
104,735 users