real time system 07 philip a lapalante 2nd edition
TRANSCRIPT
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
1/14
Queuing odels
KEY POINTSOFTHE CHAPTER
: .3 .
Prcducerhonsumernalysishould e usedo determrneheappropnatebuffersizesor buffered atawhenproduction anexceedonsumptionfor shonbu$tsBecausef lheir nherent igitalnature, iscrete robabilitymodels rebestusedwhenmodelingeal imesystemsAn MM/l qDeueanbeusedo model simplenteruptdriven eaftimesystem
Thischapter rovtdes brief nfioductiono queuingheory nd ts applicationnrheanalysis f real-time ystems,nddiscussespplicationn theprcdiction fbuffer sizes and in performancemeasutementThe reader s assumedo befamiliarwith heconceptsf expenment,vent' ample pace, ndprobability foccurence nterestedeaders howish opursueheslDdy f queumgheoryngreater etailshould onsult he reatmentsilen in [28]and 82]'
10.1 PROBABILITY UNCTIONSThe most mportant onceptn the mathematical odeling f a sysem s therardomvariable. randomvariahles a funclion hat maPselements f thesample pace,hesetof outcomeso some xPdment' nto ihe real ine Iftlesample paces discrete,hen he andom ariables sajdrobe a dtscreteoMomrdri;ble. If thesample Paces continuous,hen he andomariables sard o be
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
2/14
Chap.0 r QueuingModelsa continuousandoman,rbleWewill use heappropriateiscrete r continuousrandom ariables nd associatedrobability rstnbutionso descnbe rocessesdependingn thenafure f thunderlyingample paceFor example,hearrivaltimeofan nteruptcanbemodeled y acontinuousandom ariable, her%shenumber f packetseceivedy a cefiain rocesss modeled y a dtscreteandomvariable.
10.1,1ContlnuousThe continuous eal-valued unction/is calleda prcbabilit\t densit, nctnn orprobabiliry distribwion for t}le continuousnndom vaiable X lf the followineconditlonshoid:
flr) > 0 for all -r e illflr) d, = |
Theprcbabilitythat the randomvariableX takeson a valuebetweena and r,denoted (a < X < b) is givenbyp(a
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
3/14
Sec 102 I DiscreE u3
P =0Figur 0.l TheGaussan robabllltyunction ith F = 0 and0: = |
Figure 0: TheexponentialisLribulion
I EXAMPLE,1O.3TheWeibull isLriburionor a rdndofrariable isgiven yl i l ) = " B P - ' - - ' / > o 00 )
where > 0 md p > 0. Thegraphs f theWeibdllProbabilityensityuncdonor vdiousvaluesof rhepamete^ o andp aregiven n FLg!re 0 3 I
10.2DISCRETEThe real-valued iscrete unction/ is a calleda prcbabiliry distributian unctionor probabilit! dislributio, for the discrete andomvariableXifthe folowing threeconditionshold:
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
4/14
Chap 0 I QueuingModels
Figure 10.3 The weibull prcbability tunction or different p and o = l
1. /(i) > 0 for all lalues t X.2. >J) = l. where rangesover valuesof X.3 The probability that the random variable X tates on a value i, denotedp(X = .r), s siven by /(i).
Some ommon iscrcte rcbability istdbutionsncludea discreteorm ofunifom distribution,he binomialdisttibutlon, nd hePoisson istribulioLI EXAMPLE 0.4A fEquendyuseddiscEleprobab ty distibnlion, be Poisson ishbution s used ophenonna n which the occurenceof individual events s independeni f my PreviouFomally, it rs definedas (r 0' --P,(t = k!with t,/ > 0 Plr) de.otes the probabihtyof t occuren@s n time r, atd I r ihe@cuEences er unit lime. Nore that theprobrbility distribution of the inlemrivdl lime 'rLbetw@n two consecutiveevents) n a Poissonproce$ is given by $e ex?onentialdisdbulionwith mean.The Poissonprccess s a good model for many naturally occuringphenomena.n a Poissonprocess, heprcbabilitydistribution or lheoccufiences in time I is Poisson, and the probability distribution of &betweenoccufences is exponential We will be ushg ihese lwodistibutrons xclusively.
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
5/14
Sc.10.3 BasicBulTer izeCalculat'on
10.3BASICBUFFEB IZECALCULATICINu5
Figure10.4 Butrering ystem
10.3.1Handling urstsol DataIf both P(l) and C(t) arc constant,denotedP and C, respectively-tnd ii'r^'consumption mte C is grealer than or equal to P, then no buffer is needcd since+lie
handle the ovedlow a burst of penod f, note that the total dala Produced s Pawhile the total data coosumedn that time is CZ Thus, there s ail excessol
Recall hata buffer s a selof memo4/ ocationshatprovide emporarytoragefor dafa hatarebeingpassedrom oneprocesso ailother,when hereceiving
calleda burstperncl.To visualizehisscenario,magine n oil funrrel laced ver hecrankcase
being ost?The nextsectionseek o examinehisproblem
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
6/14
246
Thrs s how muchdatamustbe storedn thebuffer.Thus, he buffersize s
Chap. 0 r QueuingModels(P C)T (10 )
B = ( P C ) T$here C is the consumption ate, P is the production rate, and I is the bursttimeI EXAMPLE0.5A devicesprcvidingataoa real ime omputeriaDMAat9600 ytevsecondn busts f one'second urdtron vcry20 seconds he compdLers clpableof processi.ghe data t E00bytevsecondAssumrngheres suliicient ne ro empry hebufferbeioreanother u6t occurswhatshould he inidum buiiersizebe?Usingequation0 6 yields
B = (9600 E00) = 8800bytes
(106)
(r0.7)Thus, we need to know when B(O is a maximum to detemine the rcquiedbuffer size. Note that when p(l) and c0) are constant,hen equation10.7becomes quation 0.6 seeExercises).
Handlingdala that occur n burstswilh equatlon 06 is possible nly if thebuffer can be emptled eforeanofher ulst occurs.For example,n Exanple105, emptyinghebufferw l take11 seconds sufTicrentimebefore henextexpected urst If bwstsoccur oo ftequently,henno stzebufferw l avail. nthjs case he systems unstable, ndeitherupgradrnghe processorr down-grading he production rocesss necessaryo solve he problem
10.3.2 Variable Buffer Size CalculationIt is oftennot accuate o assumehatproduction ndconsumptionatesaswellas productionimesare fixed; they wili ftequently e variable.In thrs sectionwe examine casem whichprcduction nd consumptronrates are variable Although we will pedolm the analysis for continuousvariables, he results can be adapted or discretevanablesby replacmgsummaiion or integrahonm the formulas. n addltion, they can be generalizedto handle oth hediscrerc ndcontinuousases y employilgRiomann-Stieljesintegrationsee, or example,163])Suppose e havea producer rocesshatproducesan at a rategivenbythe functionp(t) AIso supposehat another ask consumes r uses he dataproduced y the i rst taskat a late detemined y the funchon.(l). The dataareproduced uringa burstpedod = t2 -,r, where 1 and 12 epresenthestart and finish times of the burst- Then the buffer sizeneededat time I > 4can be exDresseds
B(7) = tp(r)- c(t)) dt
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
7/14
Sc 10I r BasicBufferSizeCalculation
I EXAMPLE10.6A taskproducesataal a rare in bytes ersecond)har s d.refr,nedby the uncrion
wth r.oprcsentingheblnt periodThe dalam c.nsutued y a rask t a ratedeternined y rhe
Theeraphsor pG)and G) de depidedn Figure 0 5 Thequest'onhen s: f thebuatperiodsknown o be 1.5 econds,hat s thenaessary uffer ize?n biscaset canbe seen y nspecling
FiguE 10.5 Producered consumd distribnlion fu.ctions
the reai ndert le wes for4r) ed.(4 r f iar 'drn m|B rp(r=d/,orr=1. 6 Plueerngdds inio equalion 10.?,B(16) = Ip
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
8/14
28 Cbap. 0^ l r 1 1 6 - l r qI00o0ll/8) lo + l0il00(2)l, 10000(5/E)L
10000(3/8)l0(X,0(3.22) 10000(5/8X26 l)6000bytes
r Queuin8Models
variably detemined by function r.(r), then for at u \ t t ) .l lr(r\ - c(t\ ldt 110.8)
I EXAMPLE 0.7In theprevjDusxmple.f lhebusr sta$s t a jmedereminedy heGausio distribution
tnenu(0)= 0.053991 nspectingJreproduction d consDnprionbes again bows har teddinum butrersib is needed ben i = 0.053991RecatculaLionf rhe butrersize nowyieldsB(os199l) = Iplt)- c(t)l dl
= l0m0 I$ - 1t4t)l dl
= loooo(3iE)i""""'= l00(n(3/8)t0-0029151l lbyles I
Determining hen hrmaximum uffer size s neededs easilydoneb)graphinghe consumer nd producerunction cu es,and hen nspecting hem odeterminewhen the differ,ance n the areasunder the cuaves s atest, Useequation10.7 o determine his differenceand thus the maximumbuffer size.
10.4CLASSICAL UEUINGHEORYThe classicalqueuingprol)lem involves one or moreprcdueerprocessesalledseners alLdone or mort) coDsumerprocesses alled calomer,r, A standardnotation or a queuingsyslem s a three-ruple. he first component escdbesbeprobabilitydislribution for ihe time betweenarrival of customers, he secondtheprobabilitydistlibution of tjme needed o serviceeachcustomer, nd he thirdis the number of servers (seeFigure 10.6). ln a real{ime system, he firsrcohponentmight be tbe arr val timeprobabililydistribution or a certain ntem.FrcqDest,he secondwould b e the ime neededo service hat nterrupt equestadthe third componentwoulC be "1" for a single-processing ystem, morc for
If theburstperiod s alsobursloccuringat trme t,
L(t) = == e- -T
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
9/14
249I CldlsrcalQueujn8 heory
Figure10.6ComPonenLsf a queuing
multiprocessingystemsWecanuse nownPropertiesf thismodelopredictserviceimesor tasksn areal_timeystemThe M/M/l Queue
available.*" *iU presenf these results without denvation Fufiher study of theheorel icai \pects anbe ound nl28lor lS2l Fofexample elNbethenumbeloi *.tot*rs '' tr'" qu"ue t'ellinB p = I/F rhen he average umberof cu\tomer5in the queue in such a systemis
(10.9)
with varianceJ - (I p)'?
The averageime a customer pendsn the systemsI /!L
l - pThe random variable y for the dme spent In thedistribution
s()') = P(1 - P)tP('-Ptwith ) > 0.
(10 .11systemhas pmbbilit\
(10101
'10.4.1
(10 .1 : ,
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
10/14
250 Chap 10 r QueuingModelsFmally, tcarlbeshown82] hat heprobabilityhatat east rcustomen rein thequeues
P [ > f t j o s y s t e o r ] = p r (10.3)In the MA4/l model, the probabilily of exceedinga certain number olcustome$ in the system decreasesgeometrically, f interrupt requests areconsidered ustomersn a ceflain system, hen wo such equestsm the systematthe same ime (a trme overloadedcondition) have a far greaterprobability ofoccurrence han thrce or more such requests, hus, building systems hat cantoleratea single ime-overloadwill contrjbutesignificantly o system eliabllity,while worrying aboutmultrple ime-overload onditionss probablynot wofth lhebother Let us now show how the MA4/1 queue can be used in real-tlmesyslems,
'10.4.2Serviceand ProductionRalesConsider an MA4/l system in which ihe customer reprcsentsan interuptrequestof a certain lTe ard the se er reprcsents heprocessingequired orthat req est. ln this single-processormodel, waiters m the queuercpresentatime-overloadedondition. ecausef the naiureof the arrivalandprocessingtimes, this condition could theoretically occur. Suppose,however, that youcould vary either the arrival or theprocessingimes.Varying the arrival time,which is rpresented y the parameter could tle accomplished y changinghardwareor altenngtheprocess ausing be rterrupt. Changing heprocessngtime, represented y lhe parameterp, corild be accomplished y one of thetechniques iscussedn Chapter9. In any case, ixing one of theqe woparamete$,and selecting secondparametern sucha way as to reduce heprobability that more thaDone intefrupt will be in the systemsimultaneously,will ensfie that time-overloadingcannot occur wilhin a specific confidencinreflal.
I EXAMPLE10.8Suppoie ihe meo inteluval time belweenntempt rcqDests,s tued to be l0 milliseconds -eus find themq4 processingme, l, necessaryo gueetee that heprcbabilityof tine-ovedoadint(nore thd one inienpt requestn Lhesy3ten) is lets than 1',6 We cd use eqration 10.13as
Pr>2 i t rsys ,enr( ; l= , "
6.or . _.1/;
= ltootXto to1'
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
11/14
5d 104 I Cla$icalQueuing heory
I= < 0001 second
Thus, hemeo gocessingime,i, should eno hore than millisecondo Sueanletat dne_ove.loadingannot ccurwith 99%coifidence- II EXAMPLE 0.9Supposewe fix l. {he mean seflice line, to be 5 mrlliteconds,md seek o find the avenge aEivartine, i, necesary to gua.anreehat the rcbability ofiime ovedoadinsh les thd l% We can useequation10.13ds follows
< 0 0 1
j i l > ro1=+->0.050secondA
Hence, the average nlelarival time beNeen two inrenll reqDestsshould be at leastmillisecondso gueantee nly a l% risk of lime'overlodding
2Sl
0'50I
Igtg
herly'
10.4.3MoreBufterCalculalionsA secondmodel using he l\4A/Vl queueportrays he "customers"as data beingplacedn a buffer The"service"ime s lhe timeneededo pickup thedatabysome onsumerask.Hereour k[owledge f MA4/1queuess used o calculatetheaverage uffersizeneededo hold the datausingequa'tion 0.9,and heaverageimea datum Pendsn the systemitsage)usingequation 011I EXAMPLE 0.10A prccessprodnces ata with ,ntermival tihes givenby the eJgonflriat dist ibution rk a, and hconsumed y,apr@e$ at a dle Srvenby theexponentidl islribution 5d 5'.To calculale$e aveaserdmber f dal! ren! In $e butrer,se equdnon 09:
- P 4 / 5N = = - = 4l p l 4 / 5
The aveEge"age" of I dala tem co be calcul.led with equation10111rltL \157 = - = - = l s e c o n dl - p 1 4 1 5
A prcbabilitydistribution or the randomvariabledeterminhg b ate of tudatumcan be found by qsinge4ualion10.12.
l 1 3 a s
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
12/14
10.4.4
Cbtp l0 I QueuingModels
Response-Time odelinqirEDPvrrev " - handlingan inkrrupt requesl n lheTte _average response me for a prccess'""" _o .,,re.l if an MA/V! nodelil:;:JT:tJ":H"ililH"I;1#;'fxr*,n.t* #::lblenceof othercompenngproc
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
13/14
Sec.10.6 Edang\ Fomula10.5 LITTLE'S LAW
An imponantesultn queuingheory,litfu'r 1dlr, assome pplicationn real_timesystem erfomance rediction. irtle s a\ twhichappearidn 196l) slaresthal heavetage umber f customersn a queuing ystem, ,_ is equal o theavemge rrivalmteof the customerso tha!system,"u, imes he avetageimesPentn thatsystem, av
If ft serversarepresent,$en
where ",, v s the average rival rate or customerso serer i and ,.rv s lheaverage ervice ime for serverLViewing ach rocesssa seflerand nterrDpt rrivals scusfomers,ittle-slaw canbe usedasa roughestimateor CpUutilizationn sporadic,eriodic, rmixedinterruptsystems.For example, systems known ohavepeiodic nterup$occufiing t lu,20 and 100 millisecondsalld a spomdic nterrupt that is known to occur onavemge very I second.The average rocessingime for thesenterruptss 3, E,25,and30milliseconds.henby Litde's aw theavemge umber f customersnrnequeues
N," = (1/10)3+ (1/20)E (1/100)25 (1/1000)30 0.98This esults thesame ne re obtained y usingequation .7 n Chapterof the ext.Remembethatalthoughhis s anestimatefaverage pUurilizadon,fanstentoverloadsmight still be present, s we will see n the followinc
secuon.10.6 ERLANG'SFORMULA
assume hat the avemgeservice process) ime s p andthe average rival time(mterruptmte) is I, then the fraction of time that all serversarebusy (a rifte-overloaded ondition) s givenby
s(10.14)
(10.1s)
This resultdates ack o 1917!
(.\lp\-/nt>rd'Q/t')rlkl (10. r6)
-
8/9/2019 Real Time System 07 Philip A Lapalante 2nd Edition
14/14
25lt Chap. 0 r QueuingApplyingErlang's ormulao theprevious xample ivesm = 4, )r=F = 1 6 : (380^6 14/4 = 0.81l + (380/16.5) (390/16.5)2t2(380/16.5)38! (380/l6.r1t4l
This means there is a potenhal for time-ovedoading 83.4% of the time. Basedtheaverageimeloading igureof987,andwhatwe earnedromanalysis (707, or less timeloading is needed to guaGntee no overloacls rpefect world), this seems reasonable.
10.7EXERCTSESl. In Exanple l0 5 whar would b the requiredburer size or a Crven ine / if rhewere at 2400 baud,2 secondsong, md occuEedevery 5 seconds?2, A prodDcer enerates ata at 1 byre pe. ?00 naoseconds n bu6ls of 64 ,ilobEconsumerce Md the data in 32 bit words bDronly at a Ere of one *ord dwnicrosconds alculatebeminimumiizebutre..equiredo avoidspilloveathere s enough ime betw@r bursts o empty he buffer3. Show hatq,hen beproducer d consumerarks haveconstdl rates, henequarjo!becomes quation 064, A prcduer prcce\ is l$oqn ro be rble'o procesdara r a are $d i