Announcements 4410 lets 9 17,9 19 for Tutorial on Semaphores attended Tapia Conference students who es4410 student welcome to attend Best any 9 29 Hollister B 14 2 3pm 430pm Sunday Assignment 2 hints For problem l Crated sections always terminate Non critical sections Nes is not required to terminate and might not a For problem 2 mutual exclusion protocols are work for to Nz 2 expected processes is Thurs prelim 1 10 10 Looking ahead 1 2 weeks in class Likely Naew 10 8 session
FBS 54410 9 26 2019 Beyond Semaphores Synchronization primitives shared memory Semaphore's Monitors legions Tension general.ly expoessweness Vs clarity usability Laoading errors Exploit syntax f syntax cheday compilers ran the
foo object alloe on heap monitor vars ar alloe on stack opli operation pi P2 Var locals code i 2 operation P1 P2 1 I op Var locals code initialization schematic representation of monitor
Support for synchronization and synch Muta t perkperation OPI R Opi pi locals VI t N Regulge that B holds end
monitor BB of portion buff fo N strt H o len Ntt o On Htt slob b portion insert operation a slot need buff stettler to slots Len ler 11 slots I was wal porton rmv operation a ponton need buffett vale slots H len ler slots 1 start sht I mod Ntt begin stit 0 Len O slots 0 end
a Boolean condition variables f associate Bee condition a ta n releases math lockfor Monta c wet blocks process exit monitor te unblock 1 process c continue e.ua EEhBe I Topi cortina end
monitor BB of portion buff N o strt H o len Ntt o B space Ntl slob 0 slots og condition space Lento G stuff condita Bstuff b insert portion operation if slots then space wet needas buff stettler to slots Len lent slots 1 stuff continue was wal parton RMV operation iflen other stuff wait needa.io n Vale buffett slots 11 len ler slots 1 Sth start 11 mod Nti space continue begin slit 0 Len O slots _0 end BB
eopeatT saI.EE If runs after e signal II Efe wait InBc I e signal IAB in i 17in to monitor IBO
Implemented of signayargest senates for monitor entry queue conditan queue for each condition variable for monitor urgent queue If monitor ri monitor call use add thread to entay qua then else grant access Put thread on queue for e wait a Inooke scheduler Put thread on urgent queue c signal If condita qua for c not empty run head next then invoke scheduler else on went wes An thread scheduler g g T Rn.tt Else any thread on entgque Run it
Implemented of signayargest seventies with semphs Mateen semaphumit D Vor M monitor semen semaphore Hit semaphore hit G argon 1 operated op Pfmutexm C court c court 4 if urgcounta o c wait urgeoutneurgeout l then Is.ge nEEm e signal urgcountainurgcounty 11 end often oggqgtenjqg.com qfurgcountm othf.LY Ym9uTIm
Announcements 4410 10 1 week's lectures Tutorial on this 10 1,10 3 10 6 3pm 430pm Sunday Hollister 1314 is Thurs prelim 1 10 10 Looking ahead week 11 in class Likely Kaew 10 8 session
Beyondsemaphaeskon.HN Monitor Manker Vad vars condition C Be Oprah pi R Opi locals VI 1 end c wet thread suspended thread exits Monitor a e continue Ehead blocked an runs c US thread suspends Csignal queue I on urgent thred blocked are rung
Aent monitor xaranti integer wzacnt Condition man operator vintager deposit outta ant Mor Signal end W withdraw operator integer whale ants w end do inor.ua ant ant antares to end end A cut
notify My Suppose signal operation digged.oteaue 907,1 Fife I i il I need Note Actually E E notes at that point
notify Implementater of agungatenartees for monitor entry queue conditan queue for each condition variable If monitor ri monitor call use add thread to entagquea then else grant access Put thread on queue for conditioner e wait Inooke scheduler on conditonqua for c I process c notify runnable taut made continue exeauty in monitor on eond.tn que for a htt all process c notify made runnable continue executing an monitor runnable thread scheduler Pick some it to run at most one process exeates in monitor
summaryofs.gr regimes thread exits monitor e continue thread suspends C signal or urgent queue thread continues to e notify exec in Mordor All cause thread suspended on to obtain monitor lock eventually C wait C continue immediately E signal e notify eventually Pax compare with
is tricky Use of notify too processes can Acquire when f instead of white Monitor boolean init false locked var condition Q Acquire operation ifloekedthenQ.ua G while locked Q wait end de locked true end Release operation false locked Q notify end end monitor
when using mortars Cautions INestedlocking M op call f
II Priority Inversion thread A high pro med pro B low pro C C looks mute M C yields processor to B runs long computaton B e err i i i B yields processes to A A attempts to lock mutex M blocked due to C A yields processor to B i continues long computation B f
Critical Deconstructing Monitors Regions Yet another synchronization pinata Good ref An Introduction to Prograngwiti Birrell Threads forceps mutual exclusion Monitor Cwulhin ops ideas card synch selectee mutes due to visibility rules for vars looks define regions syntax of region a Lock star M region in de end
Condition variables allow release of locks notify All wait notify Lock Var M space Condition with m stuff condefeon with M 1 m de re ion Thile N een o de space East end yal Touffffstittler mode N ler lent stuff signal end 1 re non Moto o de stuff wet end while een Tal but stiff sht Coletti med N Lem een t space signal end
associate sets of with variables each lock allows arbitrary fire grain grouping of variables associated problems if Varts each with multiple locks
Message Passing m to dest send too m receive wce Various design deasons
How to specify destfatnd sofa of msg for send for receue direct nanny sender names recewen receiver names sender 0442 charnels Processes need to know each other's Problem homes asymetric direct hang sender names receiver receiver names nobody
Synchrony causes primitue to synchronous bloday delay until some event primitive continues nonbloday asynchronous received sender delayed until msg bloclaysend client Sen g yz to e send receive val receive a b e l I send res to
Buffery capacity How many sent but not received Msgs allowed O capaaly N capacity V send as p b receive as
Recommend
More recommend