Professional Documents
Culture Documents
RoundRobinCPUSchedulingGATEFundas
GATEFundas
ALLGATERELATEDQUERIES,ARTICLESANDDISCUSSIONS
Search
Home
ComputerNetworks
TheoryOfComputation
ShortestRemainingtimefirst(SRTF)
CPUscheduling
Oct
11
2014
DBMS
OperatingSystem
Electronics&Communication
MiscellaneousexamplesonCPUschedulingwhereprocessesspendsometime
doingCPUandsometimedoingI/O
RoundRobinCPUScheduling
GATEfundas
129likes
LikePage
OperatingSystem
Share
Addcomments
RoundRobinschedulingismostpracticalschedulingalgorithmsusedforschedulingtheprocessesonto
Bethefirstofyourfriendstolikethis
theCPU.Inthisalgorithmeveryprocessisexecutedforatimequantum(timeslice)andthenpreemptedto
givechancetootherprocess.
Criteria:Timequantum(Timeslice),arrivaltime
Search
Mode:Preemptive
Search
RecentPosts
Subnetting
IPaddressing2
IPaddressing1
SolutionsofSomepreviousyearGATE
questionsonCPUscheduling
PrioritybasedScheduling
RecentComments
Feedback
Flowchartofroundrobinscheduling
Example1:Findaverageresponsetime,averageturnaroundtimeandaveragewaitingtime
P.No.
Arrivaltime
Bursttime
Timequantum=2
Solution:Inroundrobinschedulingwehavetomaintainonereadyqueueinwhichprocessesarekeptand
executedinthesameordertheyentered.
http://www.gatefundas.com/roundrobincpuscheduling/
1/5
05/08/2015
RoundRobinCPUSchedulingGATEFundas
Readyqueue:empty
P1arrivesatt=0
Readyqueue:P1
soaccordingtoflowchartB.T<=T.Q(no)soexecutetheprocessfortimequantum(i.efor2unit)remaining
timeofP1is2andsendP1toreadyqueue.Nowafter2unitP2andP3arrived
Readyqueue:P1,P2,P3,P1
NowpickP2fromreadyqueueB.T<=T.Q(no)soexecuteP2fortimequantum(remainingtimeofP2is3)
andsendP2toreadyqueue.Nowafter4unitP4andP5alsoarrived.
ReadyQueue:P1,P2,P3,P1,P4,P5,P2
NowpickP3fromreadyqueueB.T<=T.Q(yes)soexecuteP3forbursttimeandterminatetheprocess(P3
completedatt=6),After6unitP6alsoarrived.
Readyqueue:P1,P2,P3,P1,P4,P5,P2,P6
NowpickP1fromreadyqueueremainingB.T<=T.Q(yes)soexecuteP1forB.TandterminateP1(P1
completedatt=8).
Readyqueue:P1,P2,P3,P1,P4,P5,P2,P6
NowpickP4fromreadyqueueB.T<=T.Q(yes)soexecuteP4forbursttimeandterminate(P4completed
att=9)
Readyqueue:P1,P2,P3,P1,P4,P5,P2,P6
ForP5B.T<=T.Q(no)executeP5forT.Q(remainingtimeofP5is4)andsendP5toreadyqueue.
Readyqueue:P1,P2,P3,P1,P4,P5,P2,P6,P5
PickP2fromreadyqueueremainingB.T<=T.Q(no)soexecuteP5forT.Q(remainingtimeofP2is1)and
sendP2toreadyqueue
Readyqueue:P1,P2,P3,P1,P4,P5,P2,P6,P5,P2
ForP6B.T<=T.Q(no)executeP6forT.Q(remainingtimeofP6is1)andsendP6toreadyqueue
Readyqueue:P1,P2,P3,P1,P4,P5,P2,P6,P5,P2,P6
forP5B.T<=T.Q(no)executeP5forT.Q(remainingtimeofP5is2)andsendP5toreadyqueue.
Readyqueue:P1,P2,P3,P1,P4,P5,P2,P6,P5,P2,P6,P5
forP2B.T<=T.Q(yes)executeP2forB.Tandterminate(P2completedatt=18)
Readyqueue:P1,P2,P3,P1,P4,P5,P2,P6,P5,P2,P6,P5
ForP6B.T<=T.Q(yes)executeforB.Tandterminate(P6completedatt=19)
Readyqueue:P1,P2,P3,P1,P4,P5,P2,P6,P5,P2,P6,P5
ForP5B.T<=T.Q(yes)executeforB.Tandterminate(P5completedatt=21)
P1
P2
P3
P1
P4
P5
P2
P6
P5
P2
P6
P5
11
13
15
17
18
1921
Responsetime=timedifferencebetweenfirstresponseandarrivalofprocess
Eg.forP4firstresponseisat8andarrivaltimeis3soResponsetime=83=5
Turnaroundtime=completiontimearrivaltime
Waitingtime=turnaroundtimeBursttime
P.No.
Arrivaltime
Bursttime
Completiontime
Turnaroundtime
Waitingtime
Responsetime
18
17
12
21
17
11
19
13
10
Total=65
Total=44
Total=20
Averageresponsetime=20/6=3.3
Averageturnaroundtime=65/6=10.8
Averagewaitingtime=44/6=7.3
Example2:Findaverageresponsetime,averageturnaroundtimeandaveragewaitingtime.
P.No.
Arrivaltime
Bursttime
http://www.gatefundas.com/roundrobincpuscheduling/
2/5
05/08/2015
RoundRobinCPUSchedulingGATEFundas
Timequantum=3
Solution:FollowingtheexplanationofaboveexampleGANTTchartandreadyqueueofthisexampleareas
follows
ReadyQueue:P4,P5,P3,P2,P4,P1,P6,P3,P2,P4,P1,P3
P4
P5
P3
P2
P4
P1
P6
P3
P2
P4
P1
12
15
18
21
24
27
30
P3
32
33
Responsetime=firstresponsetimearrivaltime
Turnaroundtime=completiontimearrivaltime
Waitingtime=turnaroundtimebursttime
P.No.
Arrivaltime
Bursttime
Completiontime
Turnaroundtime
Waitingtime
responsetime
32
27
22
10
27
23
17
33
30
23
30
29
20
21
15
12
12
Total=128
Total=96
Total=32
AverageResponsetime=32/6=5.3
Averageturnaroundtime=128/6=21.3
Averagewaitingtime=96/6=16
Example3:Consider4processesP1,P2,P3,P4allarrivinginthesameorder.Thebursttimerequirements
oftheprocessesare4,1,8,1respectivelythenwhatisthecompletiontimeofprocessP1.Assuminground
robinschedulingwithTimeQuantum=1
a)7
b)8
c)9
d)10
Solution:Givenallprocessesarriveinsameordersotakearrivingtimeofallprocessesas0
P.No
Arrivaltime
Bursttime
Asarrivaltimesofalltheprocessesaresamesofirstplacetheprocessesinreadyqueuebasedonlowest
processnumberfirst
ReadyQueue:=P1,P2,P3,P4
Nowproceedinthesamewayasexplainedabove.
http://www.gatefundas.com/roundrobincpuscheduling/
3/5
05/08/2015
RoundRobinCPUSchedulingGATEFundas
P1
P2
P3
P4
P1
P3
P1
P3
P1
P3
CompletiontimeofP1is9
Example4:[GATE2012]Considerthreeprocessesshowninthetable
Process
Arrivaltime
Bursttime
P1
P2
P3
ThecompletionorderoftheprocessesunderthepoliciesFCFSandroundrobinwithtimequantumof2units
(a)FCFS:P1,P2,P3RR:P1,P2,P3
(b)FCFS:P1,P3,P2RR:P1,P3,P2
(c)FCFS:P1,P2,P3RR:P1,P3,P2
(d)FCFS:P1,P3,P2RR:P1,P2,P3
Solution:
P1arrivesatt=0
ReadyQueue:P1
forP1B.T<=T.Q(no)executeP1forT.Q(remainingtimeofP1is3).After2unitP2alsoarrived,sendP1
backtoreadyqueue
ReadyQueue:P1,P2,P1
ForP2B.T<=T.Q(no)executeP2forT.Q(remainingtimeofP2is5).After4unitsP3alsoarrives,sendP2
backtoreadyqueue
ReadyQueue:P1,P2,P1,P3,P2
ForP1B.T<=T.Q(no)executeP1forT.Q(remainingtimeofP1is1),sendP1backtoreadyqueue.
ReadyQueue:P1,P2,P1,P3,P2,P1
ForP3B.T<=T.Q(no)executeP3forT.Q(remainingtimeofP3is2),sendP3backtoreadyqueue.
ReadyQueue:P1,P2,P1,P3,P2,P1,P3
forP2B.T<=T.Q(no)executeP2forT.Q(remainingtimeofP2is3),sendP2backtoreadyqueue.
ReadyQueue:P1,P2,P1,P3,P2,P1,P3,P2
forP1B.T<=T.Q(yes)executeP1forB.T(P1completedatt=11)
ReadyQueue:P1,P2,P1,P3,P2,P1,P3,P2
forP3B.T<=T.Q(yes)executeP3forB.T(P3completedatt=13)
ReadyQueue:P1,P2,P1,P3,P2,P1,P3,P2
CompletionorderofprocessesinroundrobinisP1,P3,P2
ForFCFSitisstraightforwardP1,P2,P3
Ciscorrectanswer
Pleasecommentifyoufindanythingincorrect,haveanydoubtorwanttosharemoreinformationaboutthe
topicdiscussedabove.
0
Tweet
Like
Share
11
http://www.gatefundas.com/roundrobincpuscheduling/
4/5
05/08/2015
RoundRobinCPUSchedulingGATEFundas
2Comments
Recommend
www.gatefundas.com
Share
Login
SortbyBest
Jointhediscussion
meli 7monthsago
Areusurethat?MynoteshowTurnarround=completesubmited..notTurnarround=complete
arrival
Reply Share
nishantagrawal25
Submittedandarrivalmeanssamethinghere...Submittedmeanswhenjobissubmittedto
theCPUwhichissameasarrivaltime
Reply Share
WHAT'STHIS?
ALSOONWWW.GATEFUNDAS.COM
Examplesonlosslessjoindecomposition
MinimalcoverorCanonicalcoverofgiven
FDset
2commentsayearago
nishantagrawal25AC+isacbdegfororiginal
2commentsayearago
dependencysetbutwhenyouwilllookin
decomposedrelationitisonly
Subscribe
AddDisqustoyoursite
nishantagrawal25Gladtoknowthatthese
exampleshelpedyouThanksforpointingout
thetypo,It'scorrectednowPleasetellif
Privacy
2014GATEFundas
http://www.gatefundas.com/roundrobincpuscheduling/
CustomisedbyGATEFundasteam
5/5