AaJt+  `P Pp P pp`ppPPPPHH $ @d HHHH̀̀̀ff@  d Footnote TableFootnote**.\t.\t/ - :;,.!?9 ch$ j+TOCHeading1Heading2   2EquationVariables>9 ;`<<=7=P=i=;B;D;F;H <$lastpagenum><$monthname> <$daynum>, <$year>"<$monthnum>/<$daynum>/<$shortyear>J<$hour>:<$minute00> <$ampm> on <$dayname>, <$monthname> <$daynum>, <$year>"<$monthnum>/<$daynum>/<$shortyear><$monthname> <$daynum>, <$year>"<$monthnum>/<$daynum>/<$shortyear> <$fullfilename> <$filename> <$paratext[Title]> <$paratext[Heading1]> <$curpagenum> <$marker1> <$marker2> (Continued)+ (Sheet <$tblsheetnum> of <$tblsheetcount>)Heading & Page <$paratext> on page<$pagenum>Pagepage<$pagenum>See Heading & Page%See <$paratext> on page<$pagenum>. Table All7Table<$paranumonly>, <$paratext>, on page<$pagenum>Table Number & Page'Table<$paranumonly> on page<$pagenum>Heading <$paratext>EHTML Headings++A33557 A<<>>@@A;b;d;f;h;j;l;n;p;r;t;v;x;z;|;~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<<<<<< < <<<<<<<<<<< <"<$<&<(<*<,<.<0<2<4<6<8<:<<<>>> dq5+d= d;]d;L HmR;MHmRHRHRFootnote Hr@;NHr@HzHz Single LineH;O Footnote ;P  HD;Q HDHH Double LineH;R Double Line;S ;T H;U  Single Line;V HZ;W  TableFootnoted5p77 EGxR;XEGxREPwEPw TableFootnoted;^dEl d;_d1QRUX[^adgjmpsvy| %).1W/Bm }d ;ad WaHTML Mapping Table }Hd ;cHd Wa }Hd ;eHd Wa }Hd ;gHd Wa }Hd ;iHd Wa }H;kH! FrameMaker PA Source Item }H ;mH Wa HTML Item }H ;oH Wa }H;qH W aInclude Auto# } H;s H W a Comments }H;uH W a }HH;w HH W aElement }H;y#H W a New Topic? }H;{H Wa } H;} H Wa }H ; $H Wa P:Date Line }HH ;#%HH WaP }H ;$&H WaN }H ;%'H WaN } H ;&( H Wa }EH ;')EH Wa P:Reading }HEH ;(*HEH WaP }EH ;)+EH WaN }EH ;*,EH WaN } EH ;+- EH Wa }QH ;,.QH WaP:Title }HQH ;-/HQH WaH* }QH ;.0QH WaN }QH ;/1QH WaN } QH ;02 QH Wa }]H ;13]H WaP:Body }H]H ;24H]H W aP }]H ;35]H W!aN }]H ;46]H W"aN } ]H ;57 ]H W#a }iH(;68iH( W$a P:Numbered1 }HiH(;79HiH((%aLI &a Parent = OL Q'a Depth = 0 }iH(;8:iH( W(aN }iH(;9;iH( W)aY } iH(;:< iH( W*a }H ;;=H  W+a P:Heading1 }HH ;<>HH  W,aH* }H ;=?H  W-aN }H ;>@H  W.aN } H ;?A H  W/a }H(;@BH(  W0a P:Numbered }HH(;ACHH(( 1aP 2a Parent = OL Q3a Depth = 0 }H(;BDH(  W4aN }H(;CEH(  W5aY } H(;DF H(  W6a }H ;EGH  W7a P:CellBody }HH ;FHHH  W8aP }H ;GIH  W9aN }H ;HJH  W:aN } H ;IK H  W;a }H ;JLH  W<aP:CellHeading }HH ;KMHH  W=aP }H ;LNH  W>aN }H ;MOH  W?aN } H ;NP H  W@a }H ;OQH  WAa P:Footnote }HH ;PRHH  WBaP }H ;QSH  WCaN }H ;RTH  WDaN } H ;SU H  WEa }H(;TVH( WFa P:Bulleted }HH(;UWHH((GaLI Ha Parent = UL QIa Depth = 0 }H(;VXH( WJaN }H(;WYH( WKaN } H(;XZ H( WLa }H ;Y[H WMa P:Heading2 }HH ;Z\HH WNaH* }H ;[]H WOaN }H ;\^H WPaN } H ;]_ H WQa }H;^`HR! P:HeadingRuPAnIn }HH;_aHH WSaP }H<`bH WTaN }H<acH WUaN } H<bd H WVa }7H <ce7H WWa P:Indented }H7H < dfH7H WXaP }7H < eg7H WYaN }7H < fh7H WZaN } 7H <gi 7H W[a }CH<hjCH\! P:TableFootPAnote }HCH<ikHCH W]aP }CH<jlCH W^aN }CH<kmCH W_aN } CH<ln CH W`a }]H(<mo]H( Waa P:TableTitle }H]H(<npH]H((baLI ca Parent = OL Qda Depth = 0 }]H( H "W4a }©H <=?©H #W5a }H©H <>@H©H #W6a }©H <?A©H #W7a }©H <@B©H #W8a } ©H <AC ©H #W9a }»d <BF»d $W:aHTML Options Table }D»d <D»d $W;a }D»d <D»d $W<a }D <CGD %W=a }DH <FHDH %W>a }H <GIH %W?a }D <HJD &W@a Image Format }DH <IKDH &WAaIMAGGIF }H <JLH &WBa }D <KMD 'WCaBanners }DH <LNDH 'WDaN }H <MOH 'WEa }D<NPD(F! Banner ReferPA ence Frame }DH<OQDH (WGa }H<PH (WHa }D(<DSD((F)I! Copy Files  Imported by PA Rerefernce }DH(<DRTDH( F)WJa }H(<DSUH( F)WKa }DD <DTVDD F*WLa }DDH <DUWDDH F*WMa }DH <DVXDH F*WNa }Vd <DW[Vd F+WOaSystem Macros }?Vd <D?Vd F+WPa }?Vd <D?Vd F+WQa }f? <DX\f? F,WRa Macro Name }?fH <D[]?fH F,WSa Replace With }fH <D\^fH F,WTa Comments }r? =D]_r? F-WUa StartOfDoc }?rH =D^`?rH F-WVa }rH =D_arH F-WWa }~? =D`b~? F.WXa EndOfDoc }?~H = Dac?~H F.WYa }~H = Dbd~H F.WZa }?= Dce?F/[! StartOfSubPADoc }?H=Ddf?H F/W\a }H=DegH F/W]a }?=Dfh?F0^! EndOfSubPADoc }?H=Dgi?H F0W_a }H=DhjH F0W`a }?=Dik?F1a! StartOfFirstPASubDoc }?H=Djl?H F1Wba }H=DkmH F1Wca }?=Dln?F2d! EndOfFirstPASubDoc }?H=!Dmo?H F2Wea }H=#DnpH F2Wfa }?=%Doq?F3g! StartOfLastPASubDoc }?H='Dpr?H F3Wha }H=)DqsH F3Wia } ?=+Drt ?F4j! EndOfLastPASubDoc }? H=-Dsu? H F4Wka } H=/Dtv H F4Wla }&? =1Duw&? F5Wma }?&H =3Dvx?&H F5Wna }&H =5Dwy&H F5Woa }8d =8Dx|8d F6WpaCross-Reference Macros }?8d =:D?8d F6Wqa }?8d =<D?8d F6Wra }H? =>Dy}H? F7Wsa Macro Name }?HH =@D|~?HH F7Wta Replace With }HH =BD}HH F7Wua Comments }T?=DD~T? F8Wva See Also }?TH=FD?THF8w! See Also: PA <$paratext> }TH=HDTH F8Wxa }n? =JDn? F9Wya }?nH =LD?nH F9Wza }nH =NDnH F9W{a }d =QD d F:WaGeneral Macros }?d =SD?d F:Wa }?d =UD?d F:Wa }?d =WD?d F:Wa }? =YD"? F;Wa Macro Name d= d= d l d= do  WBm }d = d  <W|aHeadings Table }Hd = Hd  <W}a }Hd = Hd  <W~a }H= H =!Paragraph ForPAmat }HH= HH  =WaHeading Level }H= H  =Wa Comments }H= H >W aTitle }HH= HH  >Wa }H= H  >Wa }KH = KH  ?Wa Heading1 }HKH = HKH  ?Wa }KH = KH  ?Wa }WH = WH  @Wa Heading2 }HWH = HWH  @W a }WH = WH  @W a }cH = cH  AW a }HcH = HcH  AW a }cH = cH  AW a HHˆ=HHˆ'((  `Bogus Bakery Algorithm E,` Introduction K }Why does Lamport's Bakery algorithm used a variable called  choosing  (see the algorithm, lines 1, 4, 6, and 8)? It 0Iwis very instructive to see what happens if you leave it out. This gives an example of mutual exclusion being violated if you don't put  choosing  in. But first, the algorithm (with the lines involving  choosing  commented out) so you @#can see what the modification was: M p` Algorithm N~*`|1 var (* choosing :  shared array  [0.. n -1]  of   boolean ;*) O*`o2  number :  shared   array  [0.. n -1]  of   integer ; P`   Q`3  repeat R`?4 (* choosing [ i ] := true;*) S`u5  number [ i ] := max( number [0], number [1],, number -1]) + 1; T`@6 (* choosing [ i ] := false;*) U`\ 7   for   j  := 0  to   n -1  do begin V`U8 (* while   choosing [ j ]  do  ;*) W`G9  while   number [ j ] <> 0  and X`{ 10  ( number [ j ],  j ) < ( number [ i ], i )  do Y`11 (* nothing *); Z`12  end ; [`"13 (* critical section *) \`/14  number [ i ] := 0; ]`# 15(* remainder section *) ^`! 16 until  false; `W`'Proof of Violation of Mutual Exclusion adi* Suppose we have two processes just beginning; call them p 0  and p 1 . Both reach line 5 at the same time. Now, we'll 0v{assume both read  number [0]  and  number [1]  before either addition takes place. Let p 1  complete the line, assigning 1 to  number [1] , but p 0  block before the assignment. Then p 1  gets through the  while  loop at lines 9-11 and enters the critical section. While in the critical section, it blocks; p 0  unblocks, and assigns 1 to  number [0]  at UUline 5. It proceeds to the while loop at lines 9-11. When it goes through that loop for  j  = 1, the condition on line 9 is dntrue. Further, the condition on line 10 is false, so p 0  enters the critical section. Now p 0  and p 1  are both in the critical UU@%section, violating mutual exclusion. 1bÿ The reason for  choosing  is to prevent the  while  loop in lines 9-11 from being  entered  when process  j  is setting 'its  number [ j ] . Note that if the loop is entered and  then  process  j  reaches line 5, one of two situations arises. Either "number [ j ]  has the value 0 when the first test is executed, in which case process  i  moves on to the next process, or +number [ j ]  has a non-zero value, in which case at some point  number [ j ]  will be greater than  number [ i ]  "(since process  i  finished executing statement 5 before process  j  began). Either way, process  i  will enter the critical section before process  j , and when process  j  reaches the while loop, it will loop at least until process  i  leaves the crit@ical section. A` HHˆ=HHˆ7 l}?H =[D #?H F;Wa Replace With }H =]D"$H F;W aHead }H =_D#%H F;W!a Comments }? =aD$&? FCW"a }?H =cD%'?H FCW#a }H =eD&(H FCW$a }H =gD')H FCW%a }d =jD(.d FDW&aCharacter Macros HHˆ;"HHˆ+Ge HHˆ;$3HHˆ**l}?d =lD?d FDW'a }?d =nD?d FDW(a }? =pD)/? FEW)a Macro Name }?H =rD.0?H FEW*a Replace With }H =tD/1H FEW+a Comments }? =vD0B? FFW,a HUV ;.HUV 3Ge HUV ;05+HUV 22l H$ ;1H$ 5Ge H$ ;33H$ 44l HHˆ;4HHˆ%$$7 `Bakery Algorithm 0,` Introduction 1 This algorithm solves the critical section problem for  n  processes in software. The basic idea is that of a bakery; cus0Iutomers take numbers, and whoever has the lowest number gets service next. Here, of course, service means entry to @the critical section. 3n` Algorithm 4`k1 var choosing :  shared array  [0.. n -1]  of   boolean ; 5`t 2  number :  shared   array  [0.. n -1]  of   integer ; 6`   7` 3  repeat 8`8 4  choosing [ i ] := true; 9`z 5  number [ i ] := max( number [0], number [1],, number -1]) + 1; :`9 6  choosing [ i ] := false; ;`R 7 for   j  := 0  to   n -1  do begin <`\ 8  while   choosing [ j ]  do  (* nothing *); =`L 9  while   number [ j ] <> 0  and >`{ 10  ( number [ j ],  j ) < ( number [ i ], i )  do ?`! 11 (* nothing *); @` 12  end ; A`' 13 (* critical section *) B`4 14  number [ i ] := 0; C`# 15(* remainder section *) D`! 16 until  false; FY` Comments G*k lines 1-2:Here,  choosing [ i ]  is true if P i  is choosing a number. The number that P i  will use to enter the y@critical section is in  number [ i ] ; it is 0 if P i  is not trying to enter its critical section. HUU qlines 4-6:These three lines first indicate that the process is choosing a number (line 4), then try to assign a *U9tunique number to the process P i  (line 5); however, that does not always happen. Afterwards, P i  UU*@indicates it is done (line 6). I** }lines 7-12:Now we select which process goes into the critical section. P i  waits until it has the lowest number UUgof all the processes waiting to enter the critical section. If two processes have the same number, the 0fone with the smaller name the value of the subscript goes in; the notation (a,b) < (c,d) means jtrue if a < c or if both a = c and b < d (lines 9-10). Note that if a process is not trying to enter the *scritical section, its number is 0. Also, if a process is choosing a number when P i  tries to look at it, +@AP i  waits until it has done so before looking (line 8). AJ`line 14:Now P i  is no longer interested in entering its critical section, so it sets  number [ i ]  to 0. HHˆ;6HHˆ 66 l d;;<@H$ ;<;>H$ == l H$ ;=;H$ <Wh6April 26, 1999ECS 150 Spring 1999Page 2  HUV ;>;<@HUV ?? l HUV ;?;HUV >Wl>Last modified at  1:23 pm on Monday, April 26, 1999  HHˆ;@;>HHˆAA l HHˆ;A;HHˆ@W` }?H =xD1C?H FFW-a }H =zDBH FFW.a d=~EEd=DdFF l d=DdRCERUX[^adgjmpsvy| %).1dLeftd;Rightd ReferenceddHTMLdDHTMLd Headingsd@@ 3Mapping Table Title. @@ 3Body. f@ 3 .$.H.l..... .D.h.Code. @@ 3Footer. f@T 3 TableTitleT:Table : . f@   .$.H.l..... .D.h...Body.  f@P3TitleBody.  f@T 3Heading1Body. f@ 3Body. @@ 3Header Double Line. f@ 3 CellFooting. f@ 3 CellHeading. f@ 3 CellBody. @@ 3Mapping Table Cell. @@Mapping Table Cell. @@ Mapping Table Cell. @@ 3Mapping Table Cell. f@ 3Body. f@ 3 BodySpaced. f@ 3 Bulleted\t. f@ 3...Date. mf@ 3l. DateProject. @@ 3Header Double Line. f@T 3Heading1Body. f@ 3 Numbered.\t. f@E 3 Numbered1.\tNumbered. f@ 3 NumberedSpaced.\t. f@ 3.Reading.  f@P3TitleBody. f@$3.Line Single Line. f@ 3CellBody. f@ 3 CellHeading. f@ 3 Footnote. f@T 3Heading2Body. f@T 3 HeadingRunInBody. f@ 3 Indented. f@ 3 TableFootnote. f@T 3 TableTitleT:Table : . f@ 3 .$.H.l..... .D.h.Code. f@ 3 .$.H.l..... .D.h.Code. Hf@ 3H. LineComment. Hf@ 3H. LineComment.  3 3 3  3 ڝ33Emphasis   3EquationVariables ڝ3   BoldItalic 3Italic 3Bold 3 3       3 3 3 3ZZThinMediumDoubleThick@ Very Thin HHHHHFormat AH Mapping Table HHHHHFormat BH Mapping Tableh*|#HHHHHf$*DHH+5?HH&69?HH :C?HHH DF?HH*6 ? @ h( A B C D E h  F G H I J h  K L M N O h  P Q R S T h( UVWXYh Z[\]^h_`abc7h defghChijklm]h(nopqrh stuvwh xyz{|h(}~h h    h  h h h)h  !"#$5h%&'()Oh  *+,-.[h!/ 0 1 2 3 uh "4!5!6!7!8!h!#9":";"<"="©h ">#?#@#A#B#» %C$D$E$ $&F%G%H% %'I&J&K& &(L'M'N'')O(P(Q(((*FR)S)T)D )FU*V*W*V ,FX+Y+Z+f +-F[,\,],r ,.F^-_-`-~ -/Fa.b.c..0Fd/e/f//1Fg0h0i002Fj1k1l113Fm2n2o224Fp3q3r3 35Fs4t4u4& 4Fv5w5x58 7Fy6z6{6H 68F|7}7~7T79F888n 8F999 ;F:::: :CF ;";#;$; =  <<<<> ====? >>>K >@ ???W ?A @@@c @ AAA ;F%C&C'C(C EF)D,D-D DFF.E/E0E EF1FBFCFComment ;C ;Gd BlackT!WhiteddARedddGreendd BluedCyandMagentad YellowHeader/Footer $1Header/Footer $1Header/Footer $2Header/Footer $2IndexIndexCommentCommentSubjectSubjectAuthorAuthorGlossaryGlossaryEquationEquation Hypertext Hypertext  Cross-Ref Cross-Ref Conditional TextConditional TextPositionFMPrivatePositionFMPrivateRangeEndFMPrivateRangeEndFMPrivate HTML Macro HTML Macro M.Times.P Times-Roman FrameRoman M.Times.B Times-Bold FrameRoman M.Geneva.PGeneva FrameRoman M.Helvetica.BHelvetica-Bold FrameRoman M.Geneva.B FrameRomanM.Helvetica.BIHelvetica-BoldOblique FrameRoman M.Times.I Times-Italic FrameRoman M.Courier.B Courier-Bold FrameRomanM.I Courier Oblique.PCourier-Oblique FrameRoman M.Courier.PCourier FrameRoman>CourierGeneva Helvetica2Times#Regular#Roman MediumBoldedBoldRegular ObliqueItalicS YyW TU# tYtn٠{bwpc*g]A\0t 7Klo7d*\iWwic"٩RKqmU#^pH,~$%z=wGͳ#b=c/L /Gׇnx:}|K-a.&