Os NotesFULL
Os NotesFULL
name bons ® ushich pr?
pred ip the itieal acctin
Uy Wwe
Scanned by CamScannerVOAECbbe
gaged foe |
proces! suns?
pee white)
1
cad] tyre cplag ce") ; a tatty {| 1 ocadia cpg 0) > i
” fing Co) = ues aoction eos ly
—_ ical td Fim
: fits -{ fog Crs fates
+=
Gnubual peetuoten faile
our bye .-—- and bath proteas art
uatontes the mutual excluator)
proceas | anal prouc 2 are
* ft means
mame tune -
eection at
~.paoblun with attempt 2
The flags Qne mk GPX Wwe
ies a *
—+ goptioare eatution (attempt D
hanced vonrla qantas
[x Co}= flagcr] = folac.
_Proeeas 2
ed ea), ee
Cod= Trust 5 fa ode TAU
iS oy; J Cag Cod) | coh
— a tritical cecttimn |
flog) = “Plog til = pales
ee
Scanned by CamScanner
a ae ai
Tp euiten fates, plate
“udheh ventint trip cALHcal
bacak form the while
ty eatHteal |oO Qchieuss mutual ex Cluown
+ St dines not Athleve progace! 00 thie two pro cseseo
——— gnd deadlock 4a
Petersen aplution
tun hah.
Flagco) = flag c= jot |
vohle C1)
t
Hag Cola True s
tw =2)
soride Cflag C1 AND turn = 52) 5
—-“aaHtal_seckton —|
on
fing C01 = foulea 5
hore due to ‘turn
wieh
+ gemnpHDRe
voriatle whith
i ind a) wnheger
ow & & opeiol { ed
7 a? can be Alteos ey
initiaLicedl on 04 PO) woltt )
eon be ;
by two atomic, operatic Gir .
operation ancl vey or signal O opercdurn -
no conrert 2 uultch tn HW,
atoms e means
Scanned by CamScannerrune type
mene
(5 a variable. 04 620
tt condo pore
Somaphere S 3
_— augnalls op?
7 pfoaites)
while ( 8<20) 5
s=~4
Le I __ {
v [5% s) 2a
{ |
sees
somaphore mitbex 5
pt mnutex)
muter = '3 he.
7 Ne ewp |t | ext section
vemutex) | vemutes)
Remaindrn aections | Remaindir geet iim
a eee eee a
tplomont mukuads 2 «cebu
e uaLn aamaphore » me can J
erty eowily: propeces YB gndled waiting ®
—, Semaphore ato -Cpvoties oynehnonicotlnn)
o Thene are two typo pimaphore vanridlle
4 st counting
é) counting aeraphort 2 The value
aemaphere ean hange OWN an unneatricteal
clomain (con atore “Ory wake gen Pun
aarnapy
hort $ The value bin
only eben aad
ii) binary _ormap
Scanned by CamScannerya
@Q-© My tr be execute be ‘ Oe
qm efre Si fee ME
output
Semaphore aynes
eyne =F
Prog ran!
Proges
‘ i rey & power ot |
— Pomaphere inplemendtakine ( uy woah)
5 aha a Ak 2 Lene i f 4
Busd wooly : ony Notte —
This DUaH waiting dan be eliminated by modify
tre aarmalphort PLLUCLURE + 3
aphowe pkAuctiAe| | lusith two frelde
2
a) hoger ii) Yok
i) enkegar U vontain She vole oh pumaphere vOrue:
~ bles
wi) Wat : Te toninins nO OF procyoses Arak Ore
~~ wong”
typedos mtauck
Aunt value 5
atauct padis * uel 5
Jasmaphere i ,
\
Scanned by CamScannernm be
rt) eumaphere epeatinn 6o
wait (memaphere #4)
t
* wad
go value =~ 5 a
i Cs7 value <°) a
add tus pavews £D gust > :
It in
: Now perces Dee
} } block 09; UND Py aioli bul tn
‘pteck. Yakate
deg ried ao
* gugnall) oermaphere operation tan be
seqnal Ceomaphere rc)
S volus bt 5 a
y ($7 valuere =o} r
1 3
Aemous O protkes P fo oo leks
wakeuplP)s UY plock arate do si
' + akate
o.
—+ Sunewuonivabien hardware
» Beme hwo unethucttoms “veairy bo Uanadl
epyertt taal in astuing tre wdiical “ect ton
problem .
beskan. teat Land. at Chetan bang et)
{
boplean news 4 target s
“ banget = TAue 5
return ALS
Scanned by CamScannerfeet dee | GL AetUans 0 asol teme 1s
‘ and. eet
roplernenbat to beat - os
wMutual exelucion >|
funn:
lock £0
i Pastas)
auhtle 61)
t
urnile C teal and— oat Crock) = =I) abate ves
pritical section ; mutual
excluww
de \ a
oe Fi but net Othord
j
Note Fe
at functiin
Intel pro uasor diteo rot up part
Feat and -
re ee ee
Tand. swap Curt Eualiet, 2, wrk, expectedl,
tnt COrmpane and. wap be rev ‘,
uik femp= * valine)
y (value = = expected)
x value 2 nuovalie 5
ackunn Lerap >
atom
Bt vodue =O expected! sO
Th nao valne =
volue, tomp + 0-
volun = |
af
© mutual ex Lush up Lament o-tinn Guth Cempanre_anal- wap
Pro ceo 1 {uncitory
; ronal U1), a
: {
muha porite. (Compare -and-ewap (Llock.,0,!) $ >0)s
eed emtical Section:
lock <0)
aM tga atl Sf
Scanned by CamScanner. AL) CR CENT,
SAnather — algortthr ‘uate lat —and. at i ne a
y thattuat Lom that. Qatlepeen aw
: emtteal Section —- requiem ents -
Global vartables -
boolean watling’rJ= faloe;
boslan | lock falee
\ “i Pel white, C)- : ~
\ e uy toentud
{ are? a ais '
“Vwatkog cr) > ture 5
at lM? *Leey heue 5 I Wcal vauiable
esa ae while (waiting C8 tekey)
|e key = beok-and- aot (block);
fara, S
thie Ceiba 0 Lk | boating cya
Teltows nth pro Coat
fo entoa into
EMH Ca) @ chs
sai Hy tre (phe Horiba
TPCE fooler
i Key BOTH p,
Now Py wants 1 enter, Whi, we Om
Wes of PM
Wad p> qe hue beg = re
Scanned by CamScanner
Mlau. the cond9S, far cortad gection *
nm
Vine me nota) ie
i]a le
fork C)
—+ Mutex locks |
ete
sual “? txilunléery 5
° the hardware bead mel” tp au ‘the erttetat
geckion = problem en e1atly mactersthle.
to application programma .
2 TO 'Qusid th problem, beat tgnexr bald
a bwone tools tp adlue ge ction
problem é
. Hutex locks th used . to protect eatitcal aect Uno]
and ake pretenta viace con dition
® B pro Cees! muck 0a Li Cae. the Loek bef one entering
Ps: ip the! crittcal aectton and oe. the.
dock uthen Jt ends ike the eritical eect
a while C1) 7; &
tt
fain |
anttital ceckion
neleane Look
rn neleane
while (Lawailable) ! t nraitti eatioas
gq Qrmnlaie after } 4
2 athe, prowes asem tp be
Called a@pin lock
apinning oo
Scanned by CamScannerThe main diaad vantage
huey waiter
e while O protuss
other, protod
cockton
ay ue C)
2 That jypes 4
bennuise, the
the Ince to become
— Deadlock ane
eA deadlock
more
an
rouah loop continusely
problem
preceaios
eur thot
plement atin uw
castes! ecko
oe gto enter La Othe)
ip the COU -
4 qh
wb in
thot LAs
mutex lock UW called gpin_tetk,
prouas opine white waiting tee
aval lable
ekorvation due _to gema phere
uel Brit, uthen we ow
One Wl Biotg
can be ne
y oy watsna protest
Semaphore 30
ate 13
Fe Py
soait C8) 5 waik (BY)
t 3 mart_ 08)
eaviical - 7 ;
~ — — Psectin
yy signal ti
ergnal (8) 5 stgnal (85
Se geo
Genie (2 Sa
soy ED wc
em ents
lanai 6S) $2)
seyret C8) 52. guan 91 can ereeud,
(>
oe BT catisn $20 Wat (8), @co,
. Now execute Por PI
not (8). »
of Oy wart (s)
tocaay
deadteer, nial
Scanned by CamScannerjui0 Signal aihtogether TLD 2 pir ass OXF
{hie wip es ea
problems a Synehwonization Cvva)
— claaste.
ty produien -conatumer problery [ Bounded - buffer prvblern.
Bug en
Paro dutine
|
CORSA
Bt tb also KNOWN a0 Bounded
ao buyer gite ww boerndl
+ produc proolutes On ibm and ator Ww
b fen CON eiumer conaumes » the item farm
buffer
a a hon 2 poe bles
i) produ io wreaked to
buffer wo full
ii) jonaumera lo . thterratecl|
the buy pe u empty:
© Produce and cangumtr Chane the following
data- atauckure-
- bufhr problem
produce buct the
to consume but
tne 9 3
Gemaphere mutex ='5 U mutual en clrolon acteored
to the buffer
Semaphore empty => I] initial OL) Lhe 9 post
ont 64 “buffer ane empty
Serraphore full £03; /) zew buffer a full mea
all ore ernpy. |
Pood con.
ie
Scanned by CamScannervelalr7 : ‘ale
rerho
ian” ve et - ope
omy hort mbt = a :
He ete y ntgs coleamapaares empl Es? a
i gernoprare fue
Paoclucnr ¢
white!)
{ a did
| oe ’ digi *
(* produce a9 Lhe mw rent proor"
wack COPY)
enlay [pratt Crouben: |
jean b
ew ee ada nant prodted a the uphen -
es ge ae] @
' , r
Cons UumbA
pethobtwedalddle i
waikepull) »
wait Comubex) 5
/* pemoue an ttyun room buffer
commend by nw
premeinn = Bie AREY, an maesedtaete ry
Scanned by CamScannerelt
siete
Reader - uvatker problern
21, 22,283 --- Rn
a. Ray wh K i
Be ah A x
4s Wy 5 Wo x
Semaphore wetals
Semaphore muster = 1d
unt readcert -05
Scanned by CamScannerpinot
..
are ante eat
Unhen O philoaphr dninks » ies Ts
a mel ¢
hen coblegan - enllea gate pnatoopher ge on
+ Poon tine 10 se Po ehep attele
trim to pick off wane) : ne E
Chowtat tp hen C lyr and git ne cpropottele a
© A philopher may pick up only
4Ome . taat
© Ghe Cannet pickup oa chop tick
the neGhbourt hand nth oncpetichs ot th,
+ wanen| a huonaed philosphr hao ms
eametime, “oke eats eithout 74 aay iat
Gshen ohe firwaheds eating, oh pub Apu
the chepelicht. and otart thinking eat ee
3 ; exe
© & ‘philosphir pick up the chopalitk by oh
waikl) operdbion and — nelemeto the chops
waing — axgnal C) operation:
Serraphore ehepaticn Cs] x" 1 Sritfatice te 1,
do
4 .
Wait C chopotick Ci)s,
rat Cohopatick C Ct +14 5°)) ;
ran l uk |
\ aignal Conopoticx Ce);
ae agnot CohopeticeeC Cera s]);
Fe Batiye fer a ushitee |
f wahile Ctra)
| Chopew'uc [AFT Tata
oo'2 By
Thin guarantees tat no +O .
| retghbeu are eating amultaneorioly.
i
Scanned by CamScannerprodests become hungry at
wine kame BU zach grabs fow Lape Enbpaick,
and whe ight chopeHck i not available for Og
This ado to deadlock.
pheloapher-
qoawid
tg 9 powsthle puame des eer 220) tek ane ; .
1) allow atmoet four phitosphent to alk adnucttancovsts)
‘i, tau
- is) gutoes 2. philoopher ID peck Up hen dept chepsith
only 34 bath chopolickt Ore available.
me wan odd no. Y philocpher pict up he yt chopshth
PH Chey {vwt and then ough chopthck urhenene cue:
th numberrd philotpher prchs Up hor ngpt enmpeHice
then deft chopste «
Z z
HONSTORS-
Although armaphere proud o conuionunt ond oe
ey cant mechonim fre proctet _ynchn ni tas
DLL the Semaphore rooults Hy carer:
1) noailk Crnutex) oignal Centex’)
Cae
signa! (route) wait (mutex)
enter tintp the enttical
problam + Beusnra) proces
violating mutual
oeckion aim ultane Ovaly »
exctuainn nequecement °
2) warelenuter)
OS
wait Cm utex) _
problem ¢ deadlock occwu.
3) Suppo that a prvceod pri wadt(muter) 7%
Mnal (router) 07 bath Jett» mutual 2«cluston
b “vielakd or deadtock uth occur:
Scanned by CamScanner8) 10 qwaid tress problams » moniter & ikon Bute AY
Montes mon ter name
Ie haned voriable declaratin |
funetion pred
—_
teeta pre) "a
‘ i ’ : oae\
fuetion pnl )
I
Unittalizatinn — tede (-)
{ un one
co
Cogn ) monitor 9
> Monitor Uoage _ ox ‘i
e moniter type ) 00 ART dhak. inelidin wet of
programmer dijtned a@perdtions thot ane pro widlad
‘tuuith rjutual exclusion within tre monihr
# Schemetre view af montire
Scanned by CamScannerWd, to ume. ayntheronization schtme
0 A propsamme
can aleur cbefine vantables of type "sondern *
condition %, Ys
+ The operation 2, wake 6) means that the proteas veluedl
intnin cpaatun 2 oucpenden! linden O Untd Another
wveke. be ms ougnal () 7
me forke) ayotem call »
np ae
ole lit
a po ; er |
fore oy 5 Mone |
ie cron D,
pia 2 sug,
}
net { 1 prewassn > 2? |
(fore) mea ages vet
uscd to Create proces .
ayatern cou fant) b
talug 7 anguments ano Aetusns oO. procs tP-
You might also like