OS_Lec07_0316 - ____. _-_ _LZSE 20L!...

Info iconThis preview shows pages 1–17. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 12
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 14
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 16
Background image of page 17
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ____. _-_ _LZSE 20L! .jecfliwafiuflgggjm—__ ___. _ fipfékgé’). ' _._ _—_____._ . _.. __ ._ .. gnahrbm' faji'Qn _-_ _. __ 5:341: 4L _ __prbozxser )1 ___ __ 4W_%.__2_g1&gecaffnj_ processes EM #— _ . “agthm n * hmflflgfig c} )J ‘5’Hoimd dado. - x... _4__1L3 y} _9.__prgmLL;_.CgmmmgL___J|—$5;_. 354 F--- . _. __ - laugh-size. J! _ “95:43 (waif. _u__£_u_f£r_;x__g.m. __ng .. . _ _ 2 Lam? W_wiy_ _ Lg NJ}: . . 4? _ __ __ ____ _ _ __._._ __Wh.:.££ _JI a_5§LQJJ__ _. ___,L‘?" .fiééALof..L.M§SL1 _________..m-Qingamimoh3 ykgfll 15.0” ,f j. .3 i .._ _ ___ J ___ _ _____ ._ _ _ - err-fi_._u_,g;’:_L—og—E—a\—~b _ _ _ __ __ cg ML * __ JLLC [45:57: WjilfiLgiéwu d _ _- M —: _ .F__ ._.__.__ _ W“*'—“—f——"mrffl___' __ __,. “GAchF‘SJLZ-L alga".le _ _____ _ _ wth .113 ___ ____ __ _y La. l__ _ ___ _ ____ . 73-“ Peer 4.1 ' _ __CM Mde £53.53. Au;— ._.Hjs ‘f l-fiqe, fiMQ—mBM'I' - -- -- _ ' ---- ____.__ . - — -~ 1: __;__ ._._.-. I ' _ .L ._ musf be . Mpmtmed ‘9 a+omifcmgflj;;£5 . —-___.. _. _. __I_. _‘3_.'-‘_‘_‘__ _ _ _ _"_.__m—_._____w..... 5 , - . . . a —_.c x ‘ .- __ ‘__Afc1m:;’c, 0.E.&f¢i‘flon__fll€an$._an_ _O __ . _...._..-_.-._J=iaa:f Cempfleieg in. fig _wé‘ihmt__.. .._ iflfflfrapiL'M—a_u _ ,._ _ __._. _. ___. _ --———-§ef ——. Juli-C—ue— 4L,- C++~ AL AM: .-_ §Mp~pémenfafibn J! f- _____ _____ . ._______ ___.____. urn/(r... .cflch . . __q‘egzi_C&ueJ J\_Q‘5...._,L1L___,:pJ.34DL¢Lm $11.” _A _ fl _— __- _ 6,1 L» hzg J! I _ (figt‘akri ___ ______ _. . _ . _ __ _ __cxamreg’u.) _ciaJL __ c: ___—___).1;__C.++_J_l_ M .3551 - _ _ w\ €g_!;9g_¢9{§a+_&. ‘ — __——— ___ —.—Q—_.-:U\ god! .4; a“: "Hg-magmas, (59} Qamgnfl.» cg“. .____ (3,4! C ++ __ Q— . _ ___- _c._._..._Js_ Ag) .4. ___.. @W§wf5jfiufim . ___ _ _ __ _ _ g .. _ Whuhh is ___ _ Hoefl ..mus1’_be_.. .WpQrmcd. _ aramicaflj v — Bounded Buffer count++ could be implemented as ister1 : count I The statements “’9 Race Condition t register‘l = register1 + 1 _ * count = registerl count-H; coontw could be implemented as -— count—: l y ‘ registerZ = count - must be performed atomicafvy I Atomic operation means an operation that completes in its entirety without interruption. Race Condition : ' ' E' ' ‘ l processes access — and Race condition. The Situation where severe . manipulate shared data concurrently. The final value of the shared data depends upon which process finishes last. n To prevent race conditions, concurrent processes must be synchronized. registerZ = registerz — 1: count = registeri? . .. P-uuub‘ei' execute registerl = T2: consumer execute register2 T3: consumer execute register? " -' l T4: producer execute count = registert {count = 6 } T5: consumer execute count = r ion interleaving with “count = 5" initially: Execute register1 = count {register1 = 5} I register'l +1 {register1 :1 6} 2 count {register2 = 5} I z register2 ~ 1 {register2 a 4} egisterz {count = 4} __.___9_4D-Ui"h'cu.pé€_c__ _J_L_.__.__ _ _ __ . Lam refined {Kai The Critical-Section Problem — I l nprocesses all competing to use some shared data AL Giggles-3w I , _ —— — l Each rocess has a cede segment. called coffee! section. in _ — _ — _' which the shared aatafis EEéEéEéa.‘”‘”“'ram—“fi' 3) 1’7 — m — .- Problem — ensure that-when one rocess is executin in its critical 5 ction, no other process is allows to execute in its l -‘ — '_" cn‘tical ection. C0 “Mt” J‘ 3 C9) *1 J1 LS/ _ _._ — — — — —- fl ~—-r Cris‘ m k — — — ____._ __.._ ._ ___ © __ ___)t Lari m Qt) LésgfiifldpL/a/ ____ M2_W__QQ$EJML¥L. _M __ __ ‘—v _ _. _l...:a 34> Cpujdfladagfle/ on f. _._.;.LQL2. afic‘gfi __lQm.fl‘—e..rf _Ji _ primes; . _. N5). . "_I. _ _ _ __ _ _ ___}; mm” LL5;____L.¢;3_ _ “fit 5:493)!" '___ _ _ , . J __ _ ___ __ _ _ Wi‘iqj—Jfifljmn _ by f." ‘H'_T;"T@m _ _._~:__ __ng __Qnmi seam _. Qt}: Liner _v __ . {7min {1106’ di'onif 5 Ah:me Q_Q§Afajj_‘_qg5___ __éaaem; Era _mmifflgifimgem ‘ _ _ ______ HELL; _ ._.__._._._ .. ___ __ _______. _. .__._ i _ _. __ {MQQQ_XCJQS_.KQQ)_ _ -___:_ 434. _ .___ ____Lghymlr.-_:_J. fl.__.9____(:ow_#_ii_;g§;.;_,. ___ __.__ _ “___.[zfl—Témdmfl Segr_.._1_\.{;g. Qxflf§___;._._fa_4pi} _ __ _ .___ _-.L,ML;_.‘_..cmimf§ec_=_J_i ._.€.XEC. _Lérfl:__§€3_fo_cu;_uj—_ _______ 0.5. )\ v-3; pregmss ) ___..ShmcidWwi.._.Qfa_fggi;i? ._iinite—thLfl- , ._ ___ ___ ZML@@_JL__ ___.__ _cgm‘iL be. éosipgnea__.inqitflin¢ ‘5. _ _______ _ ___ _‘ __ ___ Bounded—Wdimg)®_._____ * _épfifiLa)i_xeqLugfl_;_LL_ __Ji_gz.+i_, . MAJ— ...... .. __ __ ___.mquenf_,!.i__accegtfi_o_.§_.11__J¢4-:3L;J_ Slag/wed dag" A] _ . _ __ . _ (bounded W.9_fi+.¢}..b_JJ_hhae,Jj_) _ [.‘L .. __ General structure of process P, n - 534.1 ~ :1; _ _ __ __ d°{ ._.__Mu_n __ _ _______ _ _ ___ 4 _.c__rLMm.n _ ._ critical section ___. .a... .31: r._fie_o_t@_u__ remainder section _ . W’VLCIEI éeciffmq }while (TRUE); mm___-__+________-___w _____ -. .. ___;____m3¢5ae_.z1_ _______ //___. ____M.__J_MK£SLM ._ _____ _ ._._ ____._______ .__3bazedclam.)1__fi.t_1ch—5wl ,4 _ ___. __..____J1_$'sau. P©C@j_fl_®fi_L..ch£éS_gL 65.44: 6.1:: _.u_ 91. ._ _ .Léa..1_¢s.31_e.;_b. .pfocesiJluLJemtsecfion.) Jl.(__;g+4_ _____.___ _______.<::1:,;3_L,¢JLLL__. oifiknfljefifiuiqugg _ Cliff. 358C.____J.L_$L‘g;4¢éd§ Egg-2:31.115 procfis;__ .;___5.L __ _ _______ __ _. ._ ._ __J§_hmd.daiq Jl.d_C_ceSS.._‘L_f_.13.L¢r-L‘If @jb- _..THN\_.2.pmcg.-MJHAQ__ ___.__ _ _ _. . ___—"Shafidaim—n—accemgwq -.. I .3 ___9 . &____ M._ ' . _____ _. ._ . ._ . _ ___ ____ ___ _ __ 124.532 ; -ggngaggga %.4w4fsm_maem .A1__-___- . ___—___..- ___ —+L4.cl39.. .H fiwde Gag— _— __WL_quj #%pmcag,__).mL_aL-_xk£m¢ .1. ___.___ _ .4145; L794)! .64). .6- 4mm ,0 L .1: L244: 411,1 ______ __ _. _ Apt;_JL,JL4&_6_fl_#9__SJ—ia_ ._ _. ._ _. __ ________ __ _____:;=9_;H_La;1 Jfinfiwm m2.L£&3JP}£LATApA,1 _ _ wwwwd _iéflfin J.Lgé_j}_ __. _— __ . __ __ __.... _-_._-. _fi , __ .I... _ __ _ ' . . _PJ7_JJ_.€Q_H13,JE__CJ.J§J___ _ ._ _ . ..___ __ CLO—MillamfiLJ. _ . mum. Amiga; . $ .. __LMhEJL.Qa.mJJQ_Q_L:_M____ ____.__ . ...Pj__JL___ ___. _._______. . _ 6}};_n_u_____ u, ;_ _ipajs;,1..—@5qung_‘i;__________ “M... __.::T _._.iwm:____w m /__ E 911 . . __.__ _— _ S/Ld.ebflszd_SaJ£'.L_5a.Ok .QS_8fl'2f5mnfs a. (E.nfij:guflfl1n.Ee_d-..te._.— M. fin. Mn_-gnm?uizr_architedams, .. _._ . .._._CfiiLSfiQLM_._..-HM_.MUUS.3SMLJ1_G.L§ . _eflfia__flmcgssfl14_sgifl__ j"n.f¢.r(up:rs._.LL_fifsmhawl (31- UD 3 .. _ ______. _. _ .CXLfiLCQj_$£§£'bh_-fl_m____ _ __ __J (Mq_51d3bglk- @_.Lc_.>_.- 1&1 L5 __ . _. _. _ ) (lack _.J\....Q.C—q.qi1:,._%___-. . a 0-5 ‘:— -————- - fiamfi.._dnin_JIfl£flfifim.__L_gLy_—QL_ .MiL. _.21- --.__7.- ‘6' t ‘_L':__ pmq..es_§_ _._ ___ _.._...__. _.._ _ ___(i’n exrf fieg‘gpn) _ m 3 r- — _-_prg. I my; “"1 lack_-.AAmi._ . - ._ ..L.l_}_s_«-. _ _ . _mb. ms. J1. .. . _____ _._ — TestAndndSetlnstruction -——---———- ___—______... H/uJJ\A£._~le,._LS¢QjJ3{ _ ..__ _____ a cm: W fljmaaasamn L1H " __ _ °_ _ _ ’Iésf mpg. word a".th Magma-__- , boolean TestAndSet (boolean *target) . F . __ i { beoflemn Efa_ hamlet“..- __LLLZD__ _ _ booleanrv=*targeti U c2194.: +70%. *target = TRUE: ___ return NZ ( \LQQHL__)J—u__ _ } (Judge) $2 Mmémx baeLMJ1__N3gMJ\..}___. _. _ W‘ um ~L5_§$E.5L_J-mc. gt, fiasfg» as H’ Yéhu’n‘j Hatmjmszflibfis plan in mm. _ . . Safas F” 5:15 filc CoMali.g.P_£b$_pjg§;_bjifl£_ _ I: Definition: _ Solu'étion using TestAndSet procle w — -—-—&C_s-‘-LJ— -- l Sihared booleanivariable lock., initialized tofalse. # — l Solution: JM._-fl_c pm; {1:1 _ . I _. ___._£z€se ____ E wh:]e(:‘:'e:'tAdrCridnSO:t1i{i-l&;ock)} “to 16”»??ng _whiM" __ ..__ ' I ’ I Pack A cute. ,__,m_4.._é.LLL.g.\;p_:fi_ __ ' critical section "* ‘ T ‘- ( cw H'an 0-? look) ElgmmLm mi£n4n_ _ lock=gFAL5E= gm a}; N m) w. m*_£L¢J<__JJ_s:J_;-§1; __ _ I! rerfiaindersactjon _x 5.4:- _{f A11; ._ ___ } whileiTRUE); . 0:2.- whflu‘ Joj-Jl) Foflx_.§;mtu.m _ZHD_. iii ALIA ll _ _._mh:flul M _ ___ . almighflw 8,9} —'-”—-— — -- fist-“Jed —-_+l- ----- -- ._. _ . _.________.o._.s_'_ar1: pfa €9.55___€;_,5T_A3; NM. ___ _ do{ ___.*_.::_________q_......-_._._._m_._ __.:_____u___._____._w__..._.__,___._____ _ 7F &__ .p..f9cm52_£_g91_.. _Jirua. £0315 J! %_._-sz r (10ch .S’Cpflm. J1 . Hate? f2 .afl.__.i'.(g£._.chJ.—&£4. 1 _cqgiiaL-..mhifl¢..__11._.94=g-_...QLFQ¢3 . .. _. .flg.c£_..J4_.Q.M:,__. __ ‘r P. L, .- p _. . . _._.___._ _ ._ __ .. . _.._.W._CO_D_¢[2JJ__. . _.____ -pm_c___._.__- . _ __ a ALA. ( '9 L153 J ".H._ _.5__w-hifl_e_gj_.¢§.-_- M _ _. _. _ _ _ -.... pfamacfgjuflsfifi U. .95.. _ ‘ 53-45 I 3... Jasrkgmmj________; ' ' _._ML.®HM_LS .3. SWQQ_LQ.A»LE¢UJ £_2A_% ——-- — - - ——- -- — - -——— —— PI.) J) gm _ _____ _£.Mdm3es_s‘.a.mmfijnflafif.i __ ~—— - .___'___4.__,m .5, ._ 1‘ 90%]! F5 ' ' _ mm— _ _ m _— _ (I- ”_ _—_ fi_— __ «clan-55¢: _ - ___ __ #Lainm r.— =.=_:|=—— --————- -—-———-———— —-—- —- — — — Solution usin‘g Swap _. 39A! .kmca Ab-Cfialfifiu— --—-- . a: ,— — l Shared Boolean variable lock initialized to FALSE; Each '_"pra'cfls' ' '— 5' t F .r-- 43! _ ______._ process hasalocai Boolean vana e ey l SolUtion: '- do{ ..______.w.hi££..4.i__défim._¢y.g . “Jig: ___ “PEEK; - _ .. a ' '- ’ 2- i n p (Swag ( key == TRUE) fix SWO? P )i 1.1-2. .. . __ __ __ A} fwap (&Iock. aka-y); __ ___ IQCfiJ)..§_. )i a._.._1__ ______ . 1’! critical section frat J13 lock=FALSE whih Ji CL;__.CthLJI 3L _ _ ______ _ cm. sec. 3i £F_oj;b_.N_zé-:afi_gn_a§4§ _ m H remaindersection _ } while (TRUE); .— . __ _ _ _. Ba 763.; in: __ __ __ _ _.___._J=4_2l;. Cliff-__‘érfic... ___. __ }iifg;. Wfiifiag. Maw. .. gablL ...e¢x_113-fxe§¢m5__ ..i;9._sw_Qfl__JL . _. _.m€gflm+fig swap AL; km; . _ fl :1 J. 4; Wawmw.) a A _ _ __ ____ Mafia-LLQXdMSFOH _ . __ ._ _ ' _. . _fi _ .. __ _._.___ _ _':49LL§L 91,51. gig; AL.” ____ Sam‘ng ___ ._ _ _.psafiaafl flf':_—::":"" H __ ._ _ . .11 ._ .__.__.___ ,_¢3Kfim. .dngL..- __ I} _ Bounded-waiting Mutual Exclusion with TestandSetO l' . i The common data structures are | boolean wafitingin] : booiean lot-‘ik : _ A; " ’ = Li. 41,34;— .. | These data stmcturE-s are initialized to falsa. “" - ' _ AL 9 a b. ;_ _ ( Swap M ('1’me Nib «meat J (a) {Ema --?Ké3:--fisrAw-asa-(Hgd<}g ——— . _ __}£fisj2m§¢11l_ ____ _ ..____ _fiur,____.£'.“_fladg_ "#1113? __ P4956. LAM ..==5g:s!fi 3; Di“ _ _, m. LulaJ'Qg J.i._,«M i” C3.._.s='1_,;9 __ «- __;Léi£fi "— . _ ‘ “Q...” _ __'__,;__.W.f_:3_tace_i~§__ :3: I II J __ T “wwwfiwwflfig _‘ ~ " ti: "III—7 fl M-l—Pmm *- __Jhe¢ém - ...
View Full Document

This note was uploaded on 05/06/2011 for the course CS 12 taught by Professor Staff during the Spring '08 term at University of Texas at Austin.

Page1 / 17

OS_Lec07_0316 - ____. _-_ _LZSE 20L!...

This preview shows document pages 1 - 17. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online