14 distrib proc mgmt deadlock
TRANSCRIPT
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
1/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" !
Distributed process management:
Distributed deadlock
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
2/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" $
Distributed deadlock
% &roblem de'inition
– &ermanent blocking o' a set o' processes tat eiter compete 'or sstem
resources or communicate *it eac oter
– +o node as complete and up-to-date kno*ledge o' te entire distributed
sstem
– Message trans'ers bet*een processes take unpredictable delas
% ,pes o' distributed deadlock
– esource deadlock
% Set o' deadlocked processes# *ere eac process *aits 'or a resource eld b
anoter process (e.g.# data obect in a database# /1 resource on a ser2er)
– Communication deadlocks:% Set o' deadlocked processes# *ere eac process *aits to recei2e messages
(communication) 'rom oter processes in te set.
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
3/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" 3
Distributed deadlock (cont.)
%Sstem state representation *it *ait-'or graps (46) – +odes are processes# P 1# P 2# etc.
– Directed edge 'rom P 1 to P 2 i' P 1 blocked and *aiting 'or P 2 to release a
resource
– Sstem is deadlocked i' tere is a directed ccle
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
4/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" 7
Deadlock in resource allocation
% Conditions 'or deadlock in resource allocation
– Mutual e8clusion: ,e resource can be used b onl one process at a time
– 9old and *ait: process olds a resource *ile *aiting 'or oter resources – +o preemption: process cannot be preempted to 'ree up te resource
– Circular *ait: closed ccle o' processes is 'ormed# *ere eac processolds one or more resources needed b te ne8t process in te ccle
% Strategies
– &re2ent te 'ormation o' a circular *ait – Detect te potential or te actual occurrence o' a circular *ait
% ,pes o' algoritms
– Deadlock pre2ention
– Deadlock a2oidance
– Deadlock detection% Special issues in distributed sstems
– esources are distributed across man sites
– ,e control processes tat control access to resources do not a2ecomplete# up-to-date in'ormation on te global state o' te sstem
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
5/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" 5
Deadlock in resource allocation: Deadlock andling strategies
(!) Deadlock pre2ention
!.a &re2ent te circular-*ait condition b de'ining a linear ordering o'resource tpes
% process can be assigned resources onl according to te linear
ordering
% Disad2antages
- esources cannot be re;uested in te order tat are needed
- esources *ill be longer tan necessar
!.b &re2ent te old-and-*ait condition b re;uiring te process to ac;uire all
needed resources be'ore starting e8ecution
% Disad2antages
– /ne''icient use o' resources
– educed concurrenc
– &rocess can become deadlocked during te initial resource ac;uisition
– uture needs o' a process cannot be al*as predicted
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
6/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" <
Deadlock in resource allocation: Deadlock andling strategies
(!) Deadlock pre2ention (cont.)
!.c =se o' time-stamps
% >8ample: =se time-stamps 'or transactions to a database – eac transactionas te time-stamp o' its creation
% ,e circular *ait condition is a2oided b comparing time-stamps: strict
ordering o' transactions is obtained# te transaction *it an earlier time-
stamp al*as *ins
% ?4ait-die@ metodif [ e (,$) A e (,!) "
altB,$ (*ait)
else
killB,$ (die)
% ?4ound-*ait@ metod
if [ e (,$) A e (,!) "
killB,! (*ound)
else
altB,$ (*ait)
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
7/19CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" E
Deadlock in resource allocation (cont.)
($) Deadlock a2oidance
– Decision made dnamicall# be'ore allocating a resource# te resulting
global sstem state is cecked - i' sa'e# allo* allocation
– Disad2antages
% >2er site as to maintain global state o' sstem (e8tensi2e o2eread in
storage and communication)
% Di''erent sites ma determine (concurrentl) tat state is sa'e# but globalstate ma be unsa'e: 2eri'ication 'or sa'e global state b di''erent sites
must be mutuall e8clusi2e
% Farge o2eread to ceck 'or e2er allocation (distributed sstem ma
a2e large number o' processes and resources)
– Conclusion: Deadlock a2oidance impractical in distributed sstems
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
8/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" G
Deadlock in resource allocation (cont.)
(3) Deadlock Detection
– &rinciple o' operation% Detection o' a ccle in 46 proceeds concurrentl *it normal
operation
– e;uirements 'or te deadlock detection and resolutionalgoritms
% Detection – ,e algoritm must detect all e8isting deadlock in 'inite time
– ,e algoritm sould not report non-e8istent (pantom) deadlock
% esolution (reco2er)
– ll e8isting *ait-'or dependencies in 46 must be remo2ed# i.e. roll-back
one or more processes tat are deadlocked and gi2e teir resources to oter blocked processes
– 1bser2ation% Deadlock detection is te most popular strateg 'or andling deadlocks
in distributed sstems
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
9/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" H
Deadlock in resource allocation:lgoritms 'or distributed deadlock detection
3) Deadlock Detection (cont.)
– Control 'or distributed deadlock detection can be:a. CentraliIed
b. Distributed
c. 9ierarcical
a.! CentraliIed deadlock detection algoritms
% central control site constructs te global 46 and searces 'or ccles% Control site an maintain 46 continuousl (*it e2er assignment) or *en running
deadlock detection (and asking all sites 'or 46 updates)
% Disad2antages: single point o' 'ailure and congestion
a.$ ,e completel centraliIed algoritm % ll sites re;uest resources and release resources b sending corresponding messages to
control site
% Control site updates 46 'or eac re;uestrelease
% or e2er ne* re;uest edge added to 46# control site cecks 46 'or deadlock
% lternati2e: eac site maintain its 46 and update control site periodicall or on re;uest
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
10/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" !0
Deadlock in resource allocation:lgoritms 'or distributed deadlock detection
3) Deadlock Detection (cont.)
b. 9ierarcical deadlock detection algoritms% Sites organiIed in a tree structure *it one site at te root o' te tree
% >ac node (e8cept 'or lea' nodes) as in'ormation about te dependent
nodes
% Deadlock is detected b te node tat is te common ancestor o' all
sites *ic a2e resource allocations in con'lict
% Deadlock is detected at te lo*est le2el
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
11/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" !!
Deadlock in resource allocation:
lgoritms 'or distributed deadlock detection (cont.)
3) Deadlock Detection (cont.)
c. Distributed deadlock detection algoritms – &rinciples
% ll sites responsible 'or detecting a global deadlock
% 6lobal state grap distributed o2er man sites: se2eral o' tem participate in detection
% Detection initiated *en a process suspected to be deadlocked
% d2antages: +o single point o' 'ailure# no congestion% Disad2antages: Di''icult to implement (no sared memor)
– ,pes o' algoritms
% &at-pusing algoritms
– >ac node builds a 46 based on local in'o J in'o 'rom oter sites
– Detect and resol2es local deadlocks
– ,ransmits to oter sites deadlock in'o in 'orm o' (*aiting pat)
% >dge-casing algoritms
– Special messages (probes) sent along edges o' 46 to detect a ccle
– 4en blocked process recei2es probe# resends it on its outgoing edges o' 46
– 4en a process recei2es a probe it initiated# declares deadlock
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
12/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" !$
Deadlock in message communication
% Mutual 4aiting
– Deadlock conditions% >ac o' a group o' processes is *aiting 'or a message 'rom anoter member o'
te group
% ,ere are no messages in transit
– Concepts
% Dependence set (DS) o' process P i is te set o' all processes 'rom *ic P i ise8pecting a message
% P i can proceed *en an o' te e8pected messages arri2e
% Deadlock in a set S o' processes
– ll processes in S are stopped# *aiting 'or messages
– S contains te dependence set o' all processes in S – +o messages are in transit bet*een processes in S
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
13/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" !3
Deadlock in message communication
% Mutual 4aiting (cont.)
– esource deadlock 2s. message deadlock
% esource deadlock – deadlock e8ists i' tere is a ccle in te 46
– process P i is dependent on process P j i' P j olds a resource tat P i needs
% Message deadlock – ll successors P j o' a process P i in S are also in S
– >8ample
% ig. !7.!
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
14/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" !7
Deadlock in message communication: Mutual *aiting (cont.)
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
15/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" !5
Deadlock in message communication
% =na2ailabilit o' Message Ku''ers – Deadlock can occur in te allocation o' bu''ers 'or te storage o' messages
in transit (>8ample: packet-s*itcing data net*orks)
!. Direct store-and-'or*ard deadlock
% >8ample:
– ,*o packet s*itcing nodes# eac using a common bu''er pool 'rom *ic bu''ersare assigned to packets on demand
– Ku''er space 'or is 'illed *it packets destined 'or K – Ku''er space 'or K is 'illed *it packets destined 'or
– +eiter node can transmit or recei2e packets: deadlock
% Solution: =se separate bu''ers# one 'or eac link
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
16/19
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
17/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" !E
Deadlock in message communication (cont.)
% =na2ailabilit o' Message Ku''ers (cont.)
$. /ndirect store-and-'or*ard deadlock:
Solution% =se a structured bu''er pool#
ierarcicall organiIed# *it N+1 le2els
( N is te ma8imum number o' ops an an
net*ork pat)
% Common pool – class 0 is unrestricted:
an incoming packet can be stored tere
% Ku''ers at le2el k (*ere 0 < k ≤ N ) are
reser2ed 'or packets tat a2e tra2eled at
least k ops so 'ar
% =nder ea2 load# bu''ers *ill 'ill 'rom0
to N
% 4en bu''ers 'ill to le2el k # ne* incoming
packets tat passed k ops or less are
discarded
% +o direct or indirect store-and-'or*ard
deadlock can occur
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
18/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" !G
Deadlock in message communication: (cont.)
% =na2ailabilit o' Message Ku''ers (cont.)
3. Deadlock in a distributed 1S using message passing 'or inter-process
communication
% non-blocking Send operation re;uires a bu''er to old outgoing messages
% >8ample !
% &rocess X as a bu''er o' siIe n
% 'ter sending n messages# bu''er is 'ull
% 4en sending message n+1# process X *ill block until su''icient bu''er is 'reed
% >8ample $
% &rocess X as a bu''er o' siIe n
% &rocess Y as a bu''er o' siIe m
% Kot bu''ers# n and m# become 'ull and te t*o processes are blocked: deadlock
% &ossible solutions% &re2ention: estimate ma8imum number o' messages in transit and allocate
corresponding number o' bu''ers
% Detection: detect deadlock and roll back one o' te processes
D dl k i i ti
-
8/19/2019 14 Distrib Proc Mgmt Deadlock
19/19
CS-550 (M.Soneru): Distributed process management – Distributed deadlock [Sta0!"# [SaS" !H
Deadlock in message communication:
=na2ailabilit o' message bu''ers (cont.)