Aahrd}   PpP   `00`P`@pHH $ @d HHHHff@  d Footnote TableFootnote**.\t.\t/ - :;,.!?&cZ%*cZTOCHeading1Heading2   PEquationVariables@}>&???@@/@L>> > > >> <$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>?HTML Headings++AGGII33557 AKKA>(>*>,>.>0>2>4>6>8>:><>>>@>B>D>F>H>J>L>N>P>R>T>V>X>Z>\>^>`>b>d>f>h>j>l>n>p>q>r>t>v>x>z>|>~>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>??????? ? ?????????? ?"?$?&?(?*?,?.?0?2?4?6?8?:?<?>?@?B?D?F?H?J?L?N?P?R?T?V?X?Z?\?^?`?b?d?f?h?j?l?n?p?r?t?v?x?z?|?~???????????????????????????????????????????????????????????????@@@@@ @ @ @@@@@N@P@R@T@V@X@Z@\@^@`@b@d@f@h@j@l@n@p@q=> @@@;#@@ @";/;2;5>@$@&@(@*@,@.@1@3@5@7@9@;@=@?@A@B==>=========================== ==$=$=$=$=$=$=$=$dq5+d= d>#d>; HmR>HmRHRHRFootnote Hr@>Hr@HzHz Single LineH靕> Footnote >  HD> HDHH Double LineH>  Double Line> > H֝>  Single Line> d5p77HZ֝>; TableFootnoted>$d?靕l d>%d1QRUX[^adgjmpsvy| %).1W,܁܁Bm }蝝d >'蝝d WaHTML Mapping Table }H蝝d >)H蝝d Wa }H蝝d >+H蝝d Wa }H蝝d >-H蝝d Wa }H蝝d >/H蝝d Wa }H>1H! FrameMaker PA Source Item }H >3H Wa HTML Item }H >5H Wa }H>7H W aInclude Auto# } H>9 H W a Comments }H>;H W a }HH>= HH W aElement }H>?#H W a New Topic? }H>AH Wa } H>C H Wa }H >E $H Wa P:Date Line }HH >G#%HH WaP }H >I$&H WaN }H >K%'H WaN } H >M&( H Wa }EH >O')EH Wa P:Reading }HEH >Q(*HEH WaP }EH >S)+EH WaN }EH >U*,EH WaN } EH >W+- EH Wa }QH >Y,.QH WaP:Title }HQH >[-/HQH WaH* }QH >].0QH WaN }QH >_/1QH WaN } QH >a02 QH Wa }]H >c13]H WaP:Body }H]H >e24H]H W aP }]H >g35]H W!aN }]H >i46]H W"aN } ]H >k57 ]H W#a }iH(>m68iH( W$a P:Numbered1 }HiH(>o79HiH((%aLI &a Parent = OL Q'a Depth = 0 }iH(>s8:iH( W(aN }iH(>u9;iH( W)aY } iH(>w:< iH( W*a }띝H >y;=띝H  W+a P:Heading1 }H띝H >{<>H띝H  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(>TVȝH( WFa P:Bulleted }HȝH(>UWHȝH((GaLI Ha Parent = UL QIa Depth = 0 }ȝH(>VXȝH( WJaN }ȝH(>WYȝH( 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(>oq]H( WeaN }]H(>pr]H( WfaN } ]H(>qs ]H( Wga }֝H >rt֝H Wha P:BodySpaced }H֝H >suH֝H WiaP }֝H >tv֝H WjaN }֝H >uw֝H WkaN } ֝H >vx ֝H Wla }띝H >wy띝H WmaP:Date }H띝H >xzH띝H WnaP }띝H >y{띝H WoaN }띝H >z|띝H WpaN } 띝H >{} 띝H Wqa }H(?|~H(r! P:NumberedPASpaced }HH(?}HH((saP ta Parent = OL Qua Depth = 0 }H(?~H( WvaN }H(? H( WwaY } H(?  H( Wxa }H ? H WyaP:DateProject }HH ?HH WzaP }H ?H W{aN }H ?H W|aN } H ? H W}a }H ?H W~a C:BoldItalic }HH ? HH WaSTRONG }H ? H WaN }H ? H WaN } H ? H Wa }H?! H! C:EquationPA Variables }HH?# HH WaEM }H?% H WaN }H?'H WaN } H?) H Wa }H ?+H Wa C:Italic }HH ?-HH W aEM }H ?/H W aN }H ?1H W aN } H ?3 H W a }H ?5H W aC:Bold }HH ?7HH WaSTRONG }H ?9H WaN }H ?;H WaN } H ?= H Wa }H??H! X:Heading & PAPage }HH?AHH Wa See Also }H?CH WaN }H?EH WaN } H?G H Wa })H ?I!)H WaX:Page }H)H ?K "H)H Wa See Also })H ?M!#)H WaN })H ?O"$)H WaN } )H ?Q#% )H Wa }5H?S$&5H! X:See HeadPA ing & Page }H5H?U%'H5H Wa See Also }5H?W&(5H WaN }5H?Y')5H WaN } 5H?[(* 5H W a }OH ?])+OH W!a X:Table All }HOH ?_*,HOH W"a See Also }OH ?a+-OH W#aN }OH ?c,.OH W$aN } OH ?e-/ OH W%a }[H?g.0[H &! X:Table NumPA ber & Page }H[H?i/1H[H  W'a See Also }[H?k02[H  W(aN }[H?m13[H  W)aN } [H?o24 [H  W*a }uH?q35uH !W+a X:Heading }HuH?s46HuH!,! USE XREF PAFMT }uH?u57uH !W-aN }uH?w68uH !W.aN } uH?y79 uH !W/a }蝝H?{8:蝝H "W0a P:Header }H蝝H?}9;H蝝H"1!THROW PAAWAY }蝝H?:<蝝H "W2aN }蝝H?;=蝝H "W3aN } 蝝H?<> 蝝H "W4a }H ?=?H #W5a }HH ?>@HH #W6a }H ??AH #W7a }H ?@BH #W8a } H ?AC H #W9a }d ?BFd $W:aHTML Options Table }Dd ?Dd $W;a }Dd ?Dd $W<a }D ?CGD %W=a }DH ?FHDH %W>a }H ?GIH %W?a }םD ?HJםD &W@a Image Format }DםH ?IKDםH &WAaIMAGGIF }םH ?JLםH &WBa }D ?KMD 'WCaBanners }DH ?LNDH 'WDaN }H ?MOH 'WEa }ԝD?NPԝD(F! Banner ReferPA ence Frame }DԝH?OQDԝH (WGa }ԝH?PԝH (WHa }D(?>SD((@)I! Copy Files  Imported by PA Rerefernce }DH(?>RTDH( @)WJa }H(?>SUH( @)WKa }DD ?>TVDD @*WLa }DDH ?>UWDDH @*WMa }DH ?>VXDH @*WNa }Vd ?>W[Vd @+WOaSystem Macros }?Vd ?>?Vd @+WPa }?Vd ?>?Vd @+WQa }f? ?>X\f? @,WRa Macro Name }?fH ?>[]?fH @,WSa Replace With }fH ?>\^fH @,WTa Comments }r? ?>]_r? @-WUa StartOfDoc }?rH ?>^`?rH @-WVa }rH ?>_arH @-WWa }~? ?>`b~? @.WXa EndOfDoc }?~H ?>ac?~H @.WYa }~H ?>bd~H @.WZa }??>ce?@/[! StartOfSubPADoc }?H?>df?H @/W\a }H?>egH @/W]a }??>fh?@0^! EndOfSubPADoc }?H?>gi?H @0W_a }H?>hjH @0W`a }??>ik?@1a! StartOfFirstPASubDoc }?H?>jl?H @1Wba }H?>kmH @1Wca }??>ln?@2d! EndOfFirstPASubDoc }?H?>mo?H @2Wea }H?>npH @2Wfa }??>oq?@3g! StartOfLastPASubDoc }?H?>pr?H @3Wha }H?>qsH @3Wia } ??>rt ?@4j! EndOfLastPASubDoc }? H?>su? H @4Wka } H?>tv H @4Wla }&? ?>uw&? @5Wma }?&H ?>vx?&H @5Wna }&H ?>wy&H @5Woa }8d ?>x|8d @6WpaCross-Reference Macros }?8d @>?8d @6Wqa }?8d @>?8d @6Wra }H? @>y}H? @7Wsa Macro Name }?HH @>|~?HH @7Wta Replace With }HH @>}HH @7Wua Comments }T?@ >~T? @8Wva See Also }?TH@ >?TH@8w! See Also: PA <$paratext> }TH@>TH @8Wxa }n? @>n? @9Wya }?nH @>?nH @9Wza }nH @>nH @9W{a }d @> d @:WaGeneral Macros }?d @>?d @:Wa }?d @>?d @:Wa }?d @>?d @:Wa }? @>"? @;Wa Macro Name d@I d@J d 靕l d@K do  W܁܁Bm }蝝d @M 蝝d  <W|aHeadings Table }H蝝d @O H蝝d  <W}a }H蝝d @Q H蝝d  <W~a }H@S H =!Paragraph ForPAmat }HH@U HH  =WaHeading Level }H@W H  =Wa Comments }H@Y H >W aTitle }HH@[ HH  >Wa }H@] H  >Wa }KH @_ KH  ?Wa Heading1 }HKH @a HKH  ?Wa }KH @c KH  ?Wa }WH @e WH  @Wa Heading2 }HWH @g HWH  @W a }WH @i WH  @W a }cH @k cH  AW a }HcH @m HcH  AW a }cH @o cH  AW a HH=HHu  V܁܁gsive access to the buffer. First, the consumer checks that there is a slot in the buffer with an item 큩deposited and, if not, waits until there is ( down ( full ) ). When there is, it waits until it can obtain 0zexclusive access to the buffer ( down ( mutex ) ). Once both these conditions are met, it can safely @extract the item. !W mlines 21-22As the consumer is done with the buffer, it signals that any other process needing to access the xbuffer may do so ( up ( mutex ) ). It then indicates it has extracted another item into the buffer @&( up ( empty ) ). !X eline 23Since the buffer is not accessed while the item is consumed, we don't need to put semaphores @around this part. A` HH=HH7 靕l}?H @!> #?H @;Wa Replace With }H @#>"$H @;WaHead }H @%>#%H @;Wa Comments }? @'>$&? @BWa }?H @)>%'?H @BW a }H @+>&(H @BW!a }H @->')H @BW"a }d @0>(.d @CW#aCharacter Macros HH;"HH❝+G܁e HH;$3HH**靕l}?d @2>?d @CW$a }?d @4>?d @CW%a }? @6>)/? @DW&a Macro Name }?H @8>.0?H @DW'a Replace With }H @:>/1H @DW(a Comments }? @<>0<? @EW)a HUV ;.HUV ❝3G܁e HUV ;05+HUV 22靕l H$ ;1H$ 5G܁e H$ ;33H$ 44靕l HH;4HHǝ007 `Producer/Consumer Problem 0,` Introduction 1܁`[This algorithm uses semaphores to solve the producer/consumer (or bounded buffer) problem. 3V` Algorithm 4 ܁h`U1 var buffer :  array  [0.. n -1]  of  item; 5t`L 2  full ,  empty ,  mutex : semaphore; 6`A 3  nextp ,  nextc :   item; 7` 4 begin 8`# 5  full  := 0; 9`. 6  empty  :=  n ; :`$ 7  mutex  := 1; ;` 8  parbegin <`: 9  repeat (* producer process *) =`: 10 (* produce an item in  nextp  *) >`2 11  down ( empty ); ?`2 12  down ( mutex ); @`9 13 (* deposit  nextp  in buffer *) A`0 14  up ( mutex ); B`/ 15  up ( full ); C`' 16  until  false; D`; 17  repeat (* consumer process *) E`1 18  down ( full ); F`2 19  down ( mutex ); G`: 20 (* extract an item in  nextc  *) H`0 21  up ( mutex ); I`0 22  up ( empty ); J`; 23 (* consume the item in  nextc  *) K`' 24  until  false; L`! 25  parend ; M` 26 end . P` Comments Q܁ lines 1-3Here,  buffer  is the shared buffer, and contains  n  spaces;  full  is a semaphore the value of which 0mis the number of filled slots in the buffer,  empty  is a semaphore the value of which is the number kof emoty slots in the buffer, and  mutex  is a semaphore used to enforce mutual exclusion (so only uone process can access the buffer at a time).  nextp  and  nextc  are the items produced by the pro@2ducer and consumed by the consumer, respectively. !R |line 5-7This just initializes all the semaphores. It is the only time anything other than a  down   or an  up @operation may be done to them. !S lline 10Since the buffer is not accessed while the item is produced, we don't need to put semaphores around @ this part. !T qlines 11-13Depositing an item into the buffer, however, does require that the producer process obtain exclusive haccess to the buffer. First, the producer checks that there is an empty slot in the buffer for the new |item and, if not, waits until there is ( down ( empty ) ). When there is, it waits until it can obtain zexclusive access to the buffer ( down ( mutex ) ). Once both these conditions are met, it can safely @deposit the item. !U tlines 14-15As the producer is done with the buffer, it signals that any other process needing to access the buffer @may do so ( up ( mutex ) ). It then indicates it has put another item into the buffer ( up ( full ) ). AV mlines 18-20Extracting an item from the buffer, however, does require that the consumer process obtain excluHH;6HH 66 靕ld>GK EGxR> EGxREPwEPw TableFootnote}?H @>>1=?H @EW*a }H @@><H @EW+a d@D??d@E>d@@ 靕l d@F>dR=?RUX[^adgjmpsvy| %).1H$ >:IH$ HH靕l H$ >:H$ GW܁܁h@April 22, 1999ECS 150 Spring 1999Page 1 HUV >:GKHUV JJ靕l HUV >:HUV ❝IW܁܁l?Last modified at 10:42 pm on Monday, April 19, 1999 HH>:IHHLL 靕l HH>:HH❝KW2܁܁e dLeftd:Rightd ReferenceddHTMLd>HTMLd HeadingsdĿ@@ QMapping Table Title. Ŀ@@ QBody. Ŀ@@ QFooter. f@T Q TableTitleT:Table : .  f@PQTitleBody. f@ QBody. Ŀ@@ QHeader Double Line. f@ Q CellFooting. f@ Q CellHeading. f@ Q CellBody. Ŀ@@ QMapping Table Cell. f@T QHeading1Body. Ŀ@@/Mapping Table Cell. Ŀ@@ /Mapping Table Cell. Ŀ@@ QMapping Table Cell. f@ QBody. f@ Q .$.H.l..... .D.h.Code. f@ Q BodySpaced. f@ Q Bulleted\t. f@ Q...Date. mf@ Ql. DateProject. Ŀ@@ QHeader Double Line. f@T QHeading1Body. f@ Q Numbered.\t. Hf@ QH. LineComment. f@E Q Numbered1.\tNumbered. f@ Q NumberedSpaced.\t. f@ Q.Reading.  f@PQTitleBody. f@$Q.Line Single Line. f@ QCellBody. f@ Q CellHeading. f@ Q Footnote. f@T QHeading2Body. f@T Q HeadingRunInBody. f@ Q Indented. f@ Q TableFootnote. f@T Q TableTitleT:Table : . f@ Q .$.H.l..... .D.h.Code. Hf@ QH. LineComment.  Q Q Q蜜 / Q Q Q )  Q Q Q/ Q    QQ蜜EmphasisQ蜜EquationVariables / 蜜 BoldItalic ۸QItalic QBoldZZThinMediumDoubleThick@ Very Thin HHHHHFormat A HHHHHFormat BH Mapping TableH Mapping Tableh*|#HHHHHf$*DHH+5?HH&69?HH :B?HHH CE?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(nopqr֝h stuvw띝h 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(((*@R)S)T)D )@U*V*W*V ,@X+Y+Z+f +-@[,\,],r ,.@^-_-`-~ -/@a.b.c..0@d/e/f//1@g0h0i002@j1k1l113@m2n2o224@p3q3r3 35@s4t4u4& 4@v5w5x58 7@y6z6{6H 68@|7}7~7T79@888n 8@999 ;@:::: :B@ ;";#;$;蝝 =  <<<<> ====? >>>K >@ ???W ?A @@@c @ AAA ;@%B&B'B(B D@)C,C-C CE@.D/D0D D@1E> >d BlackT!WhiteddARedddŝGreendd 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.Helvetica.BHelvetica-Bold FrameRoman M.Geneva.PGeneva FrameRoman M.Times.I Times-Italic FrameRoman M.Courier.ICourier-Oblique FrameRoman M.Courier.PCourier FrameRomanM.Helvetica.BIHelvetica-BoldOblique FrameRomanbCourier(Geneva. HelveticaPTimes!Regular$Roman MediumBoldRegular ObliqueItalicRAŧޢTvDIqٕ |183DoXZ֯l3+v DOyGE}j i*VWu̠xs8VW\r|H(^;X?*q8v,<522L9'_rq\)iHM