Deadlock
Deadlock
A deadlock a
iteeouon hea
ocked beclst each poc
and aleng tor anoth
held,
C
(PI Requst/
Assig,
So two
RequestJ mote
whis conilig
Aappening event
e
hapes
these
he dtate deadock.
hun
Conditien for Deadlock :
Necssa Exclusen - Two
eaewLces
-LAe at
non- shaua (ony
a time )
Held an wot i - A holoig at
Vutex
Reeces
e t i-
Sungle
Sntae Snite.
R
RI
Examp-1:
RI
R2
PI
P 2 C
Av alabte (0,0)
by bo h
he
andP2
hnc
RI
Reoat
ALocate RI p.
Puoces RI R 2
P2
P3 R R2.
(o,o)
AyailaHe
awala
the
As e them
the neeel tor ex ecte
,and
P1 anel
both
th eu
awalally
Hhe mew
do execFed
ohich suuttecun Con
thhe Po
Hene deadUo
my for cthii
Cate se uene
the P2 Pl 5 P3
P2 P3
P)
p2 P3
cate Ihe
b. wl
euted ex
avalable
Hene
be P2
isowees availa Ghe
1)(1,
PIAftu
erectd,
CatueleallO wl Leshich
ereute Sutficwnt
to
PIcess Pro be the
vla
(0,),
ttt dealo
ca the &
the
be
wl P3
k, eeled ex
equal which
to
o)(o, uquu P3
o)(o, Reoeces)
Availae
2) (@, Resrcs tal To
0
P2
RI R s0ces P
RequstR2
F3)
R2
RI
(Py
-e
A Locale
Requeat
PHocess RI, RI
RI R3
Po
Heoee - (o,0, 1 )
Av ailae
Jhe
Po
P P3
Handle the
motho d to
Deacwck 9moane i
the
micnwm thu bewing
for ond
Lday mamy maisnty
hat he
appoaes the deadla
end whee
nomal ptutt.
ory tor bresi arel al
beturem c o r t
Jhe thadott ce
- ns anel þetomae. the Os
Linux mamy Petommae
dh p entomat ysrn dseanes
diadlo ce
dudek
hanel
happens
tomply
to
mhan m
hamdg has to
3 +hesr typ ot ystom, the
tmply star he emput n he
deodLocde
Pseevention
when mutual exuson
Deadloce happen No
trypcempon nd cuclau
is p s i
wt hords rutomuey st
Lhe
the deado k Con neren
b t thee
the fou condutio
54 we tai iti phuycal
ve a bug angumet
the
drnplementaias
AveLcane
chelu whthe
Sn dado awecaee thi
iato State at
procem
whies the OS peons thu
Conin wl
One mores do nate
has to ba ch t a the sep. allncalin
C a e the
ullo caion deeu n't
dsadlo cu g the
algoithm sed for dadllo ce
Boce's Algosth n.
DeadlO ce deticliov
ot Po ceMes all
hetten
peuodeally Or not
deadloce
t appls om
to ihe Syibm
oleadto cle
BankeH'S Atgonith m i
a that Aast he
he banke'S lgonih the
and
adae algo Llo Ca Lion to
the
Safty by <i mlatibg
Pu detemned maximem Safe-stale
male
them ativtlies
tet tor
posse
llo caton
shold
Chel
whethen
dicing Lenlen!
Exampl 1: Need
BS
Total A = 10
ma
Avoa
Aotao ABc.
A B C
Poes A ABc
332
15 3
3 2
P2
y 2 2
5 33
PS
Total
- Alo calion
Avala
(io, s,)- (7 , 2,5)
= 3 , 3, 2.
-
Netd CPI]
- (o 0)
Allo catim (P))
Need Cr2] - Max P ]
-(20 o)
I22
Nced [r3] max e3] - AU (P3]
= (9 o ) -(302)
Step - 1
tor Pows PI - Londitioo folat
Ned TPI] > Avalate
Ceinnot exe t e
-
Stp
for Lon dulion
Necd CP2] Avalu
ucled.
Heme
Av ailat t
New Avaulal 20 0
Av cilal = 3 32 t
532 .
Stip -3:
p3 Condtion false
for Avalae
Ned CP3 J > exewt P3
Connot
He to P4,
P4
tondilin ttue
Need (e4]
C21e] (s,3.2)
ex ecule
ww
yailale A
Avaulati (2, I, 1)
(5,3,2 ) +
(1, 4,3)
Step - 5 !
for po ces con diton tee.
K Avalali
Need CPs ] e xected.
wiu be + AU.[p s]
Hem Avalalre
(9,4,3) + to, 0,2)
Avalal
(4,4,S).
wth PI
Pro cex P)
e staut
Nw
exete the
nemanug proase.
Stup-6.
for Ppocs PI
Conditon beu.
Need Cei) x Av aclae
exeuted.
Henee PI wl
Aatatt
(1,4) t (o,, o )
(7,s,s).
for P3
P3 wl be exeud.
Honu
P4. ’P3 P2 ’ PI
Preem
-
the he
145 P3
4S 5 33 |
3 3
2 | PI
3 3 O 3 3
Avaulate Alocation
Max
Need
P3 PI ’ ps ’ P4 P2
PYetem
llog for Yhe
the
dealo
cle withaut
eled exe the
tal To ala Av
s,7) (10, =
(3,0,
2) s,S)
+ (-1.
[P2) Au. Avalae Avalall
Exampe-8: Need
Aocain Avaiab
Pocus max
AeeD
A
A
Po |2 32
O65O
PI
||O2
P2 2
3 56
P3 653 6 33
|656
Pu
Set seguen