artigo - dete¸c˜ao de deadlock distribuído chandy-misra-haas

14
Distributed Deadlock Detection K. MANI CHANDY and University of Texas and LAURA M. HAAS IB M JAYADEV MISRA Dist ribu ted dea dlock models are p resent ed for re source and commu nicat ion deadlo cks. Simple dist ribut ed a lgorith ms for detection of these deadloc ks are given. We sh ow th at all true deadlocks are detected and that no fals e dea dlocks are reported. In our algorithms, no process maintains global information; all messages have an identic al shor t length. The algor ithms can be ap plied in dis trib uted databas e and o ther message communi cation systems. Categories and Subject Descriptors: C. 2.4 [Computer-Communication Netwo rks]: Distributed Systems--distributed applications; D.4. 1 [Operating Sys tems]: Process Management--deadlocks; synchronization; D.4.4 [Operating Systems]: Communications Management--network communi- cation General Terms: Algorithms Additio nal Key Wor ds and Phra ses: D ist rib uted deadlock detection, message communi cati on systems, resou rce deadlo ck, communicati on deadlo ck 1. INTRODUCTION In a system of processes which communicate only with a single central agent, deadlock can be detected easily because the central agent has complete infor- mation about every process. Deadlock detection is more difficult in systems where there is no such central agent and processes may communicate directly with one another. If we could assume that message communication is instanta- neous, or if we could place certain restrictions on message delays, deadlock detection would become simpler. However, the only realistic general assumption we can make is that message delays are arbitrary but finite. In this paper, we present deadlock detection algorithms for networks of processes in which there is no single central agent and in which message delays are arbitrary but finite. The only assumption we make is that messages sent by process A to process B are received by B in the order in which they were sent by A. This work has been supported by the Air Force Offic e of S cienti fic Researc h und er grant A FOSR 81- 02 05 and by the University of Texa s under a grant from the University Research Institute. Authors' addresses: K. M. Chandy and J. Misra, Department of Computer Sciences, University of Texas at Aust in, Austin, T X 78712; L. M. Haas, IBM Research, 5600 Cottle Road, Sa n Jose, CA 95193. Permission to copy without fee all or part of thi s materi al is granted prov ided t hat the copies are not made or distributed for dir ect commerc ial advantage, the ACM c opyrigh t notice and th e title of the publi cation and its date appear, and notice is given that copying is by permission of the Associ ation for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specific permission. © 1983 ACM 0734-2 071/83/ 0500-014 4 $00.75 AC M Transacti ons on Comput er Systems, Vol. 1, No. 2, May 198 3, Pages 144-156 .

Upload: fernando-henrique

Post on 10-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 1/13

D i s t r i b u t e d D e a d l o c k D e t e c t i o n

K. MANI CHANDY and

University of Texas

andLAURA M. HAAS

I B M

JAYADEV MISRA

Distributed deadlock models are presented for resource and communication deadlocks. Simpledistributed algorithms for detection of these deadlocks are given. We show that all true deadlocks aredetected and that no false deadlocks are reported. In our algorithms, no process mainta ins globalinformation; all messages have an identical short length. The algorithms can be applied in distributeddatabase and other message communication systems.

Categories and Subject Descriptors: C.2.4 [C om pu te r- Co mmun ic at io n Networks]: DistributedSystems--distributed applications; D.4.1 [Oper at ing Sys tems]: Process Management--deadlocks;synchronization; D.4.4 [Operating Systems]: Communications Management--network communi-cation

General Terms: Algorithms

Additional Key Words and Phrases: Distributed deadlock detection, message communicationsystems,resource deadlock, communication deadlock

1. INTRODUCTION

In a sys tem of processes which communica te only wi th a s ing le cent ra l agent ,

deadlock can be de tec ted eas i ly because the cent ra l agent h as comple te in for -

mat i on abo ut every process . Deadlock de tec t io n i s more d i f f icu l t in sys tems

where the re i s no such cent ra l agent and processes may communica te d i rec t ly

wi th one another . I f we could assume tha t message com mun ica t i on i s ins t an ta -

neous, or i f we could place cer ta in restr i c t ion s on message delays, deadl ock

de tec t ion would become s imple r . However , the only rea l i s tic genera l a ss ump t io n

we can make i s tha t message de lays a re a rb i t r a ry but f in i te . In th is paper , we

present deadlock de tec t ion a l gor i thms for ne tworks of processes in which t he re

is no s ing le cent ra l agent and in which message de lays a re a rb i t r a ry but f in i te .

The only assump t io n we make i s tha t messages sen t by process A to process B

are rece ived by B in the order in which they were sen t by A.

This work has been supported by the Air Force Office of Scientific Research under grant AFOSR 81-0205 and by the University of Texas under a grant from the University Research Institute.Authors' addresses: K. M. Chandy and J. Misra, Department of Computer Sciences, University ofTexas at Austin, Austin, TX 78712; L. M. Haas, IBM Research, 5600 Cottle Road, San Jose, CA95193.Permission to copy without fee all or part of this material is granted provided that the copies are notmade or distributed for direct commercial advantage, the ACM copyright notice and the ti tle of thepublication and its date appear, and notice is given that copying is by permission of the Association

for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specificpermission.© 1983 ACM 0734-2071/83/0500-0144 $00.75

ACM Transactionson Computer Systems, Vol. 1, No. 2, May 1983, Pages 144-156.

Page 2: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 2/13

Distributed Deadlock Detection 145

W e c o n s i d e r tw o d e a d l o c k m o d e l s in m e s s a g e c o m m u n i c a t i o n s y s t em s : r e s o u r c e

a n d c o m m u n i c a t i o n d e a d lo c k s . D e a d l o c k d e t e c t i o n a lg o r i th m s a r e g i v en f or b o t h

m o d e l s . M o s t d e a d l o c k m o d e l s i n d i s t r i b u t e d d a t a b a s e s a r e r e s o u r c e d e a d l o c k

m o d e l s [ 3, 4 , 5 , 8 , 1 0, 11 , 1 2, 14 ]; i n t h e s e m o d e l s , d e a d l o c k a r i s e s b e c a u s e p r o c e s s e s

m a y w a i t p e r m a n e n t l y f o r r e s o u r c e s h e l d b y e a c h o th e r . T h e c o m m u n i c a t i o n

d e a d l o c k m o d e l i s b o t h m o r e a b s t r a c t a n d m o r e g e n e r a l ; i t i s a p p l i c a b l e t o a n y

m e s s a g e c o m m u n i c a t i o n s y s t e m .

I n t h e r e s o u r c e m o d e l , a p r o c e s s w h i c h r e q u e s t s r e s o u r c e s m u s t w a i t u n t i l i t

a c q u i r e s al l t h e r e q u e s t e d r e s o u r c e s b e f o r e it c a n p r o c e e d w i t h i t s c o m p u t a t i o n .

F o r e x a m p l e , a p ro c e s s m a y r e q u e s t r e s o u r c e s a , b , a n d c; t h e p r o c e s s c a n p r o c e e d

o n l y a f t e r r e c ei v in g a ll th r e e r e s o u r c e s - - a , b , a n d c . T h e c o m m u n i c a t i o n m o d e l

i s a p p l i ca b l e t o a r b i t r a r y r e s o u r c e r e q u e s t s i n v o l v i n g th e l o g ic a l p r o c e s s e s A N D

o r O R . F o r i n s t a n c e , a p r o c e s s m a y r e q u i r e r e s o u r c e s a and e i t h e r b or c; i f i t

r e c e i v e s a, i t c o n t i n u e s t o w a i t f o r e i t h e r b or c; i f i t r e c e i v e s b f i r st , i t m u s t c a n c e l

i ts r e q u e s t f o r c a n d c o n t i n u e t o w a i t fo r a . I n g e n e r a l in t h e c o m m u n i c a t i o nm o d e l , u p o n r e c e i v i n g a n y o n e r e s o u r c e t h e p r o c e s s s e n d s c a n c e l l a t i o n m e s s a g e s

i f n e c e s s a r y a n d w a i t s f o r a n e w s e t o f r e s o u r c e s. A l t h o u g h t h e d e a d l o c k d e t e c t i o n

a l g o r i th m g i v en fo r t h e c o m m u n i c a t i o n m o d e l c a n b e a p p l i e d t o t h e r e s o u r c e

m o d e l , t h e a l g o r i t h m g i v e n i n th i s p a p e r f o r t h e r e s o u r c e m o d e l is s i m p l e r.

M a n y a l g o r i t h m s i n th e l i t e r a t u r e a r e i n c o r r e c t i n t h a t t h e y e i t h e r fa i l t o r e p o r t

s o m e g e n u i n e d e a d l o c k s o r re p o r t d e a d l oc k s w h e r e n o n e e x is t. W e s h o w t h a t o u r

a l g o r i t h m s f o r b o t h m o d e l s d e t e c t a l l g e n u i n e d e a d l o c k s a n d r e p o r t n o f a ls e o n es .

D i j k s t ra a n d S c h o l t e n p r e s e n t e d a n a l g o r i t h m t o d e t e c t t e r m i n a t i o n i n d i ff u si ng

c o m p u t a t i o n s [ 2 ]. D i f f u s in g c o m p u t a t i o n i s a m o d e l o f d i s t r i b u t e d c o m p u t a t i o n s

i n w h i c h t h e c o m p u t a t i o n i s s t a r t e d b y a s p e c i a l p r o c e s s , t h e ini t iator, w h i c hs e n d s o n e o r m o r e m e s s a g e s. P r o c e s s e s o t h e r t h a n t h e i n i t i a t o r c a n s e n d m e s s a g e s

o n l y a f t e r re c e i v i n g a m e s s a g e . E a c h p r o c e s s i s r e a d y t o r e c e i v e m e s s a g e s f r o m a l l

o t h e r p r o c e s se s a t al l t im e s . T h u s t h e c o m p u t a t i o n t e r m i n a t e s o n l y w h e n e v e r y

p r o c e s s is i dl e, w a i ti n g f o r e v e r y o t h e r p r o c e s s . O u r c o m m u n i c a t i o n m o d e l i s

i n t e n d e d t o s u p p o r t i m p l e m e n t a t i o n s o f l a n g ua g e s s u c h a s C S P [7 ], a n d t h e r e f o r e

w e m u s t a l l o w ( 1) a p r o c e s s t o w a i t s e l e c t i v e l y f o r m e s s a g e s f r o m some ( n o t

n e c e s s a r i ly al l) o t h e r p r o c e s se s , a n d (2 ) a n y p r o c e s s t o s e n d a m e s s a g e w i t h o u t

h a v i n g r e c e i v e d a m e s s a g e . A s a c o n s e q u e n c e , w e m u s t d e t e c t d e a d l o c k i n o u r

m o d e l w h e n a n y subse t o f p r o c e s s e s w a i t f o r e a c h o t h e r , w h e r e a s i n th e D i j k s t r a

a n d S c h o l t e n m o d e l , t e r m i n a t i o n i s d e t e c t e d o n l y w h e n all p r o c e s s e s a r e w a i t in gf o r a ll o t h e r s . A n a l g o r i t h m f o r t e r m i n a t i o n d e t e c t i o n o f d i ff u s in g c o m p u t a t i o n s

i n c o m m u n i c a t i n g s e q u e n t i a l p r o c e s s e s a p p e a r s i n [ 1 3 ] .

R e s o u r c e a n d c o m m u n i c a t i o n d e a d l o c k m o d e l s a r e i n t r o d u c e d i n S e c t i o n 2. A n

a l g o r i t h m f o r t h e r e s o u r c e m o d e l i s g i v e n i n S e c t i o n 3 a n d o n e f o r t h e c o m m u n i -

c a t i o n m o d e l i s g i v e n i n S e c t i o n 4 . I m p l e m e n t a t i o n i s s u e s a r e d i s c u s s e d i n S e c -

t i o n 5 .

2. A MODEL OF DISTRIBUTED COMPUTATION

A n e t w o r k c o n si s t s o f a s e t o f p r o c e s se s w h i c h c o m m u n i c a t e w i t h o n e a n o t h e r

e x c lu s iv e ly b y m e s s ag e s. W e a d o p t t h e m e s s a g e c o m m u n i c a t i o n p r o t o c o l o fD i j k s t r a a n d S c h o l t e n [ 2]: a n y m e s s a g e s e n t b y o n e p r o c e s s t o a n o t h e r is r e c e i v e d

c o r r e c t l y a f t e r a n a r b i t r a r y b u t f i n it e d e la y , a n d m e s s a g e t r a n s m i s s i o n s o b e y t h e

A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l . 1 , N o . 2 , M a y 1 9 8 3 .

Page 3: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 3/13

146 K .M . Chandy , J . M is ra , and L . M. Haas

f i rs t - in - f i rs t - o u t r u le , t h a t is , m e s s a g e s s e n t b y a n y p r o c e s s P i t o a n y o t h e r p r o c e s s

Pj are r e c e iv e d b y P i i n th e s e q u e n c e i n w h i c h t h e y w e r e s e n t b y P i . T h e s e

r e q u i r e m e n t s c a n b e m e t b y u s in g s e q u e n c e n u m b e r s a n d t i m e - o u t s [ 9 ] a n d b y

h a v i n g e v e r y p r o c e s s p o l l p e r i o d i c a ll y f o r i n p u t m e s s a g e s .

A p r o c e s s P i c a n a s s e r t o n l y t h a t a n y m e s s a g e i t s e n d s t o p r o c e s s P j w i l l b er e c e i v e d eventually , H o w e v e r , p r o c e s s P i c a n n o t a s s e r t t h a t P j h a s a c t u a l l y

r e c e iv e d t h e m e s s a g e u n l es s i t r ec e i v e s s o m e f o r m o f a c k n o w l e d g e m e n t f r o m P j.I n o u r m o d e l , a p r o c e s s n e v e r w a i t s t o s e n d a m e s s a g e . I n C S P [ 7] , b y c o n t r a s t ,

a p r o c e s s P i c a n s e n d a m e s s a g e t o a p r o c e s s P j o n l y w h e n P j i s w i l l i n g t o r e c e i v e

t h e m e s s ag e . T h e C S P p r o t o c o l is i m p l e m e n t e d i n o u r m o d e l b y h a v i n g t h e

m e s s a g e s e n d e r f i r s t s en d t h e m e s s a g e a n d t h e n w a i t f or a n a c k n o w l e d g m e n t ; t h e

m e s s a g e r e c e i v e r s e n d s a n a c k n o w l e d g m e n t u p o n r e c e iv i n g t h e m e s s a ge . T h u s ,

t h e s e n d e r c a n p r o c e e d w i t h i ts c o m p u t a t i o n o n l y a f t e r t h e r e c e i v e r h a s r e c e i v e d

t h e m e s s a ge .

A t a n y g i v e n t im e , a p r o c e s s i s in o n e o f t w o s t a t e s : i d l e o r e x e c u t i n g . O n l yp r o c e s s e s t h a t a r e i n th e e x e c u t i n g s t a t e c a n s e n d m e s s a g e s . A n e x e c u t i n g p r o c e s s

m a y c h a n g e i t s s t a t e ( t o i d l e ) a t a n y t i m e . A n i d l e p r o c e s s m a y c h a n g e i t s s t a t e

( to e x e c u ti n g ) o n l y a f t e r it s r e q u e s t s h a v e b e e n g r a n t e d ; t h e c o n d i t i o n s f o r t h i s

s t a te c h a n g e a r e d i f f er e n t f o r r e s o u r c e a n d c o m m u n i c a t i o n m o d e l s a n d a r e

d e s c r i b e d i n t h e f o l l o w i n g s e c t i o n s .

2 .1 R e s o u r c e M o d e l

W e s t u d y t h e r e s o u r c e d e a d l o c k p r o b l e m a s i t a r i s e s i n d i s t r i b u t e d d a t a b a s e s

( D D B s ) . A D D B c o n s i s t s o f resources, controllers , a n d processes. A s s o c i a t e d

w i t h e a c h c o n t r o l l e r is a s e t o f r e s o u r c e s w h i c h i t m a n a g e s a n d a s e t o f c o n s t i t u e n t

p r o c e s se s . A p r o c e s s c a n o n l y r e q u e s t r e s o u r c e s f r o m i ts o w n c o n t r o l l e r, b u t t h i s

c o n t r o l l e r m a y h a v e t o c o m m u n i c a t e w i t h o t h e r c o n t r o l le r s in o r d e r t o r e s e r v e

t h e p a r t i c u l a r r e s o u r c e . A p r o c e s s c a n n o t e x e c u t e u n l e s s i t a c q u i r e s a ll t h e

r e s o u r c e s f o r w h i c h i t i s w a i ti n g . A s e t o f p r o c e s s e s i s sa i d t o b e d e a d l o c k e d w h e n

n o p r o c e s s in t h e s e t c a n e x e c u t e b e c a u s e e a c h p r o c e s s r e q u i r e s a r e s o u r c e h e l d

b y s o m e o t h e r p r o c e s s in t h e s e t . B e l o w i s a m o r e f o r m a l d e s c r i p t i o n d e r i v e d

f r o m [ 12 ].

A D D B is i m p l e m e n t e d b y N c o m p u te rs $ 1 , . . . , S N. A l o c a l o p e r a t i n g s y s t e m

o r controller Cj a t e a c h c o m p u t e r Sj s c h e d u l e s p r o c e s s e s , m a n a g e s r e s o u r c e s , a n d

c a rr ie s o u t c o m m u n i c a t i o n . T h e r e a r e M transac t ions T1 . . . . . T M r u n n i n g o n t h e

D D B . A t r a n s a c t i o n i s i m p l e m e n t e d b y a c o l le c t io n o f p roc e s ses w i t h a t m o s t o n e

p r o c e s s p e r c o m p u t e r . E a c h p r o c e s s is l a b e l e d w i t h a t u p l e P~j w h e r e T i i s t h e

i d e n t i t y o f t h e t r a n s a c t i o n t h a t t h e p r o c e s s b e l o n gs t o a n d S j is th e c o m p u t e r o n

w h i c h t h e p r o c e s s ru n s .

A t s o m e s t a g e s in a t ra n s a c t i o n 's c o m p u t a t i o n i t m a y n e e d t o lock r e s o u r c e s

( s u c h a s f i l e s ) . W h e n a p r o c e s s P~j n e e d s a r e s o u r c e , i t s e n d s a r e q u e s t t o i t s

c o n t r o l l e r Cj. I f Cj m a n a g e s t h e r e s o u r c e , a n d i f t h e p a r t i c u l a r r e s o u r c e i s a v a i la b l e ,

i t m a y a c c e d e t o t h e r e q u e s t i m m e d i a t e l y ; o t h e r w i s e , t h e p r o c e s s h a s t o w a i t t o

a c q u ir e t h e r e q u e s t e d r e s o u rc e . I f t h e r e q u e s t e d r e s o u r c e i s m a n a g e d b y s o m e

o t h e r c o n t r o l l e r C m , t h e n Cj t r a n s m i t s t h e r e q u e s t t o p r o c e s s P i n v i a c o n t r o l l e r

Cm ; n o w p r o c e s s P ~ r e q u e s t s t h e r e s o u r c e f r o m i ts c o n t r o l l e r C~ . W h e n P ~a c q u i r e s t h e r e q u e s t e d r e s o u r c e f r o m C m, i t s e n d s a m e s s a g e t o P ij ( v i a C m a n d

A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l. 1 , N o . 2 , M a y 1 9 83 .

Page 4: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 4/13

Distributed Deadlock Detection 147

C j ) s t a t i n g t h a t t h e r e q u e s t e d r e s o u r c e h a s b e e n a c q u i r e d . P ij m a y p r o c e e d w i th

i t s c o m p u t a t i o n o n l y a f t e r it h a s r e c e i v e d p o s i t i v e r e p l i e s t o a l l o f i ts r e q u e s t s f o r

r e s o ur c e s. W h e n p r o c e s s e s in a t r a n s a c t i o n T i n o lo n g e r n e e d a r es o u r c e m a n a g e d

b y c o n t r o ll e r C m, t h e y c o m m u n i c a t e w i t h p r o c e s s Pim w h i c h i s r e s p o n s i b l e f o r

r e l e a s i n g t h e r e s o u r c e t o C m. M e s s a g e s s e n t b y a n y c o n t r o l l e r Ci t o a n o t h e r Cj,a r r i v e s e q u e n t i a l l y a n d i n f i n it e t i m e .

A p r o c e s s c a n n o t p r o c e e d w i t h i t s c o m p u t a t i o n u n t i l i t a c q u i r e s every r e s o u r c e

t h a t i t r e q u e s t e d . A s e t o f p r o c e s s e s i s s a i d t o b e idle w h e n i t i s w a i t i n g t o a c q u i r e

a r e s o u r c e ; i t is s a i d t o b e e x e c u t i ng w h e n i t i s n o t i d l e. T h u s , i f a p r o c e s s n e v e r

a c q u i r e s a r e q u e s t e d r e s o u r c e , i t i s p e r m a n e n t l y i dl e. W e a s s u m e t h a t i f a s i n g le

t r a n s a c t i o n r u n s by i t s e l f i n t h e D D B , i t w i ll t e r m i n a t e i n f in i te t i m e a n d

e v e n t u a l l y r e l ea s e a l l r e s o u r ce s . W h e n t w o o r m o r e t r a n s a c t i o n s r u n i n p ar a l l e l,

d e a d l o c k m a y a ri se .

F o r n o t a t i o n a l s i m p l i c i t y w e a s s i g n a s i n gl e i d e n t i f y i n g s u b s c r i p t ( r a t h e r t h a n

a d o u b l e s u b s c r i p t ) t o a p r o c e s s ; P ~ d e n o t e s t h e i t h p r o c e s s . W e r e f e r t o a p r o c e s s ' sc o n t r o l le r a n d t r a n s a c t i o n e x p li c it l y ( r a t h e r t h a n b y u s i ng s u b s c ri p t s ). T h e u s e o f

a si n gl e s u b s c r ip t r a t h e r t h a n a d o u b l e s u b s c r i p t d o e s n o t a l t e r t h e p r o b l e m a t a ll ;

w e m e r e l y r e n u m b e r a ll t h e p r o c e s s e s i n t h e s y s t e m w i t h 1, 2 , 3 . . . . . A p r o c e s s P ji s s a i d t o b e d e p e n d e n t o n a n o t h e r p r o c e s s P k i f t h e r e e x i st s a s e q u e n c e (seq) o f

p r o c e s s e s Pj , Pi (a ) . . . . . P i (m) , P k, w h e r e e a c h p r o c e s s i n seq i s i d le a n d e a c h

p r o c e s s ( e x c e p t t h e f i r s t) i n seq h o l d s a r e s o u r c e f o r w h i c h t h e p r e v i o u s p r o c e s s

in seq i s w a i t i n g ; P j i s d e f i n e d t o b e l oc a l l y de pe nde n t o n P k i f a l l t h e p r o c e s s e s

in seq b e l o n g t o t h e s a m e c o n t r o l l e r. I f P j is d e p e n d e n t o n P k t h e n P1 m u s t r e m a i n

i d le a t l e a s t a s l o n g a s P k r e m a i n s i dl e. P j i s d e a d l o c k e d i f i t i s d e p e n d e n t o n i t s e l f

o r o n a p r o c e s s t h a t i s d e p e n d e n t o n i ts e lf . I n e i t h e r c a s e , d e a d l o c k e x i s t s o n l y ift h e r e i s a c y c le o f i d le p r o c e s s e s e a c h d e p e n d e n t o n t h e n e x t p r o c e s s i n t h e c y c le .

T h e g o al o f r e s o u r c e d e a d l o c k d e t e c t i o n a l g o r i t h m s i s t o d e c l a r e t h a t d e a d l o c k

e x i s t s i f a n d o n l y i f s u c h c y c l e s e x i s t .

2 .2 C o m m u n i c a t i o n M o d e l

T h e c o m m u n i c a t i o n m o d e l i s a n a b s t r a c t d e s c r i p t io n o f a n e t w o r k o f p r o c e s s e s

w h i c h c o m m u n i c a t e v i a m e s s a g e s . T h e r e a r e n o e x p li c it c o n t ro l l e rs ( o r r e s o u r c e s)

i n t h is m o d e l ; c o n t r o ll e r s m u s t b e i m p l e m e n t e d b y p r o c es s e s ; r e q u e s t s f o r r e s o u r c e

a l lo c a ti o n, c a n c e ll a ti o n , a n d r e l e a s e m u s t b e i m p l e m e n t e d b y m e s s a g e s .

A s s o c i a t e d w i t h e v e r y i d l e p r o c e s s i s a s e t o f p r o c e s s e s c a l l e d i t s de pe nde n t s e t .A n i dl e p ro c e s s s t a r t s e x e c u t i n g u p o n r e c e i v in g a m e s s a g e f r o m a n y p r o c e s s i n i ts

d e p e n d e n t s e t; o t h e r w i s e , i t d o e s n o t c h a n g e s t a t e o r i t s d e p e n d e n t s e t . A p r o c e s s

is t e r m i n a t e d i f i t i s i d le a n d i t s a s s o c i a t e d d e p e n d e n t s e t is e m p t y . F o r t h e

m o m e n t , w e a s s u m e t h a t p r o c e s s e s d o n o t t e r m i n a t e , f ai l, o r a b o rt ; t h e s e i s s u e s

a r e c o n s i d e r e d i n S e c t i o n 5 .

I n t u i t i v e l y , a n o n e m p t y s e t S o f p r o c e s s e s i s d e a d l o c k e d i f a l l p r o c e s s e s i n S a r e

p e r m a n e n t l y i dl e. A p r o c e s s i s p e r m a n e n t l y i dl e if i t n e v e r r e c e i v e s a m e s s a g e

f r o m a n y p r o c e s s in i t s d e p e n d e n t s e t.

I t is n o t p o s s i b l e t o d e t e c t p e r m a n e n t i d l e n e s s i n t h e f o l lo w i n g s i tu a t i o n .

P r o c e s s A i s w a i t i n g f o r a m e s s a g e f r o m p r o c e s s B ; p r o c e s s B i s c u r r e n t l y

e x e c u t i n g a n d w i ll s e n d a m e s s a g e t o p r o c e s s A o n l y u p o n c o m p l e t i o n o f a l o o p ;p r o c e s s A a p p e a r s t o b e p e r m a n e n t l y i dl e i f p r o c e s s B ' s lo o p c o m p u t a t i o n i s

A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l . 1 , N o . 2 , M a y 1 9 8 3 .

Page 5: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 5/13

148 K .M . Chandy, J . Misra, and L. M. Haas

n o n t e r m i n a t i n g . D e t e c t i o n o f p e r m a n e n t i d l e n es s o f t h i s t y p e a m o u n t s t o so l v in g

t h e h a l t in g p r o b l e m a n d h e n c e is u n d e c i d a b l e . W e m u s t t h e r e f o r e a s s u m e i n t h i s

s i t u a t i o n t h a t A i s n o t p e r m a n e n t l y i dl e si n ce B may s e n d i t a m e s s a g e s o m e t i m e

i n th e f u t u re . T h e r e f o r e w e a d o p t t h e f o l lo w i n g o p e r a t i o n a l d e f i ni t io n o f d e a d lo c k .

a n o n e m p t y s e t o f p r o c e s s e s S is deadlocked [ 1 5] i f a n d o n l y i f

1 . A l l p r o c e s s e s i n S a r e i d l e ;

2 . T h e d e p e n d e n t s e t o f e v e r y p r o c e s s i n S i s a s u b s e t o f S ; a n d

3. T h e r e a r e n o m e s s a g e s in t ra n s i t b e t w e e n p r o c e s s e s i n S .

A p r o c e s s i s deadlocked i f i t b e l o n g s t o s o m e d e a d l o c k e d s e t.

A n o n e m p t y s e t S o f p r o c e s s e s s a t i s f y in g th e a b o v e t h r e e c o n d i t i o n s m u s t

r e m a i n i d le p e r m a n e n t l y b e c a u s e (1 ) a n i d le p r o c e s s Pi i n S c a n s t a r t e x e c u t i n g

o n l y a f te r r e c ei v i n g a m e s s a g e f r o m s o m e p r o c e s s Pj i n i t s d e p e n d e n t s e t , (2 ) e v e r y

p r o c e s s Pj i n P i ' s d e p e n d e n t s e t is al so i n S a n d c a n n o t s e n d a m e s s a g e w h i le

r e m a i n i n g i n t h e i d l e s t a t e , a n d (3 ) t h e r e a r e n o m e s s a g e s in t r a n s i t f r o m Pj t o P i ,

w h i c h i m p l i e s t h a t Pi w i ll n e v e r r e c e i v e a m e s s a g e f r o m a n y p r o c e s s i n i t s

d e p e n d e n t s e t .

2 . 3 A C o m p a r i so n o f R e s o u r c e a n d C o m m u n i c a t io n D e a d l o c k s

T h e r e a r e se v e r a l d i f fe r en c e s b e t w e e n t h e r e s o u r c e m o d e l a n d t h e c o m m u n i c a t i o n

m o d e l . O n e c r i t i c al d i ff e r e n ce is t h a t i n t h e c o m m u n i c a t i o n m o d e l , a p r o c e s s c a n

k n o w t h e i d e n t i t y o f t h o s e p r o c e s s e s f r o m w h i c h i t m u s t r e c e i v e a m e s s a g e b e f o r e

i t c a n c o n t i n u e. I f p r o c e s s A n e e d s t o r e c e i v e a m e s s a g e f r o m p r o c e s s B , t h e n A

c a n k n o w t h a t i t i s waiting for B. T h u s , t h e p r o c e s s e s h a v e t h e n e c e s s a r y

i n f o r m a t i o n t o p e r f o r m d e a d l o c k d e t e c t i o n i f t h e y a c t c o l le c t i v e ly . I n th e r e s o u r c e

m o d e l t h e d e p e n d e n c e o f o n e t r a n s a c t i o n o n a c t io n s o f o t h e r t r a n s a c t i o n s i s n o t

d i r e c t l y k n o w n . A l l t h a t i s k n o w n i s w h e t h e r a t r a n s a c t i o n i s w a i t i n g f o r a g i v e n

r e s o u r c e o r w h e t h e r a t r a n s a c t i o n h o l d s a g i v en r e s o u r c e . A c o n t r o l l e r a t e a c h s i te

k e e p s t r a c k o f i ts r e s o u r c e s a n d o n l y t h e c o n t r o l l e rs c a n d e d u c e t h a t o n e

t r a n s a c t i o n is w a i t i n g fo r a n o t h e r . T h u s t h e a g e n t o f d e a d l o c k d e t e c t i o n i n t h e

t w o e n v i r o n m e n t s i s n o t t h e s a m e .

T h e s e c o n d m a j o r d i f f e r en c e is t h a t i n a r e so u r c e a l l o c a ti o n m o d e l a p r o c e s s

c a n n o t p r o c e e d w i t h e x e c u t i o n u n t i l i t r e c e i v e s all t h e r e s o u r c e s f o r w h i c h i t is

w a i ti n g. I n C S P a n d s i m i l a r c o m m u n i c a t i o n m o d e l s , a p r o c e s s c a n n o t p r o c e e d

w i t h i ts e x e c u t io n u n t i l i t c a n c o m m u n i c a t e w i t h at least one o f t h e p r o c e s s e s f o r

w h i c h i t i s w a i t i n g. F o r i n s ta n c e , a p r o c e s s i n C S P e x e c u t i n g a g u a r d e d c o m m a n dm a y w a i t to r e c e i v e f r o m s e v e r a l p r o c e s se s ; a g u a r d s u c c e e d s a n d e x e c u t i o n

c o n t i n u e s w h e n a m e s s a g e i s r e c e i v e d f r o m any one o f t h e s e p r o c e s se s . T h e

d i ff e r e nc e b e t w e e n t h e r e s o u r c e m o d e l a n d t h e c o m m u n i c a t i o n m o d e l i s b e t w e e n

wait ing for all resources a n d wai tin g for any one message; t h i s d i f f e r e n c e r e s u l t s

i n v e r y d i f f e r en t a l g o r i t h m s f o r t h e t w o m o d e l s .

I n g r a p h - t h e o r e t i c t e r m s , d e a d l o c k a r i s es in t h e r e s o u r c e m o d e l w h e n t h e r e i s

a cycle o f ( id le ) d e p e n d e n t p r o c e s se s , w h e r e a s in t h e c o m m u n i c a t i o n m o d e l t h e r e

m u s t b e a knot 1o f ( i d l e ) w a i t i n g p r o c e s s e s .

T h e c o m m u n i c a t i o n m o d e l is m o r e g e n e ra l t h a n t h e r e s o u rc e m o d e l . I n p a r t ic -

u l ar , t h e r e s o u r c e m o d e l c a n b e s i m u l a t e d a s a c o m m u n i c a t i o n m o d e l . F u r t h e r -

' A v e r t e x i o f a d i r e c t e d g r a p h i s a k n o t i f a l l v e r t i c e s t h a t c a n b e r e a c h e d f r o m i c a n a l s o r e a c h i .

A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l . 1 , N o . 2 , M a y 1 9 8 3 .

Page 6: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 6/13

Distr ibuted De adlock Detection 149

m o r e , th e c o m m u n i c a t i o n m o d e l c a n h a n d l e t h e c a s e w h e r e a p r o c e s s w a i t s fo r a

l o g ic a l c o m b i n a t i o n o f r e s o u r c e s , a s i n r e s o u r c e a a n d r e s o u r c e b o r r e s o u r c e c .

3 . D E A D L O C K D E T E C T IO N IN T H E R E S O U R C E M O D E L

A g r e a t d e a l o f e ff o r t h a s g o n e i n t o d e v e l o p i n g a d i s t r i b u t e d a l g o r i t h m f o rd e t e c t i n g r e s o u r c e d e a d l o c k s i n d i s t r i b u t e d d a t a b a s e s ( D D B s ) [2 , 3 , 6 ]. I n a r e c e n t

p a p e r , G l i g o r a n d S h a t t u c k [ 3] s t a t e t h a t " r e n e w e d i n t e r e s t in d i s t r ib u t e d s y s t e m s

h a s r e s u l t e d i n t h e p u b l i c a t i o n o f a t l e a s t t e n p r o t o c o l s f o r d e a d l o c k d e t e c t i o n .

H o w e v e r , f e w o f t h e s e p r o t o c o l s a r e c o r r e c t a n d f e w e r a p p e a r t o b e p r a c t i c a l ."

B e l o w , w e p r e s e n t a s o l u t io n [ 1] t o t h i s p r o b l e m .

I n o r d e r t o d e t e r m i n e w h e t h e r a n i d l e p r o c e s s i s d e a d l o c k e d , i t s c o n t r o l l e r

i n i t i a t e s a p r o b e c o m p u t a t io n . I n a p r o b e c o m p u t a t i o n , c o n t r o l le r s se n d m e s s a g e s

c a l l e d p r o b e s t o o n e a n o t h e r . P r o b e s a r e c o n c e r n e d e x c l us i v el y w i t h d e a d l o c k

d e t e c t i o n a n d a r e d i s t i n c t f r o m r e s o u r c e r e q u e s t s a n d r e p li e s. P r o b e c o m p u t a t i o n s

m a y b e i n i t ia t e d f o r s e v e r a l p r o c e s se s , a n d t h e s a m e p r o c e s s m a y h a v e s e v e r a lp r o b e c o m p u t a t i o n s i n i t i a t e d f o r i t i n s e q u e n c e .

A p r o b e i s a t ri p l e ( i, j , k ) d e n o t i n g t h a t i t b e l o n g s to a p r o b e c o m p u t a t i o n

i n i t ia t e d b y P i, a n d t h a t t h i s p r o b e i s b e i n g s e n t f r o m p r o c e s s P j o n o n e c o n t r o l le r

t o p r o c e s s P k o n a n o t h e r . T h e i n t u i t iv e m e a n i n g o f a p r o b e ( i , j , k ) i s a s f ol lo w s .

P j s e n d s p r o b e ( i , j , k ) t o P k w h e n t h e f o l l o w i n g c o n d i t i o n s e x i s t : P i i s i d le , P j is

w a i t i n g f o r ( i . e . , w a i t i n g t o a c q u i r e r e s o u r c e s f r o m ) P h , a n d P j h a s d e t e r m i n e d

t h a t P i is d e p e n d e n t o n P j . T h i s p r o b e m a y b e d i s c a rd e d o r a c c e p t e d b y P h ; th e

p r o b e i s a c c e p t e d b y P k i f a n d o n l y i f P k is id l e, P k d i d n o t k n o w t h a t P i w a s

d e p e n d e n t o n it , a n d P k c a n n o w d e d u c e t h a t P i i s d e p e n d e n t o n i t. I t f o ll o w s t h a t

i f P i a c c e p t s a p r o b e ( i , j , i ) , f o r a n y j , t h e n P / i s d e a d l o c k e d .

3 . 1 A l g o r i t h m

T h e c o n t r o l l e r m a i n t a i n s a B o o l e a n a r r a y de pe nde n t k f o r e a c h c o n s t i t u e n t p r o c e s s

P k , w h e r e d e p e n d e n t k ( i) i s t rue o n l y if P k ' s c o n t r o l l e r k n o w s t h a t P i is d e p e n d e n t

o n P k . I f d e p e n d e n t i ( i ) is t rue, t h e n P i i s d e p e n d e n t o n i t s e lf a n d h e n c e i s

d e a d l o c k e d . I n it ia l ly , d e p e n d e n t i ( j ) is s e t fa l se f o r al l i a n d j . T h e d e t a i l e d

a l g o r i t h m f o r t h e p r o b e c o m p u t a t i o n is g i v e n be l ow .

F o r i n i t i a ti o n o f p r o b e c o m p u t a t i o n b y a c o n t r o l l e r fo r a c o n s t i t u e n t i d l e p r o c e s s

P i:

i f P i i s l o c a ll y d e p e n d e n t o n i t s e l f(i.e., Pi be longs to a dead locked se t o f p rocesses ,a ll o n t h e s a m e c o n t r o l l e r )

t h e n d e c la r e d e a d lo c ke l s e f o r a l l P , , P b s u c h t h a t

(i ) Pi i s l o c a ll y d e p e n d e n t o n P , , a n d( i i) Pa i s wa i t ing fo r Pb , and

( ii i) P , , Pb a re on d i f fe ren t con t ro l le r s ,send probe( i , a , b ) .

F o r a c o n t r o l l e r o n r e c e i v i n g a p r o b e ( i , j , k ) :

i f

(i) Pk is idle, and( i i ) dependen tk( i ) = fa l se , and

( ii i) Pk has n o t rep l ied (pos i t ive ly ) to a l l r eques t s o f Pj,

• A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l . 1, N o . 2 , M a y 1 9 83 .

Page 7: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 7/13

150 K.M. Chandy, J. Misra, and L. M. Haas

t h e n b e g i nd e p e n d e n t s ( i ) = t r u e ;i f k --- it h e n d e cl ar e th a t P i i s dead lockede l s e f o r a l l P ~ , P b su c h t h a t

( i) Pk i s loca l ly dep end en t on P , , and( ii ) Pa i s wa i t ing fo r Pb , and

( ii i) Pa an d Pb a re on d i f fe ren t con t ro l le r s ,send prob e( i , a , b ) .

e n d

F o r a c o n t r o l l e r w h e n a c o n s t i t u e n t p r o c e s s P k b e c o m e s e x e c u t in g :

s e t d e p e n d e n t s ( i) = f a l s e f o r a l l i

T h e p r o o f t h a t a p r o c e s s is a c t u a l l y d e a d l o c k e d w h e n i t is d e c l a r e d t o b e s o

f o ll o w s f r o m t h e f a c t ( w h i c h m a y b e s h o w n b y i n d u c t i o n ) t h a t d e p e n d e n t k ( i) i s

t rue o n l y i f P i i s d e p e n d e n t o n P k a n d P k i s i dl e. C o n v e r s e l y , w e c a n p r o v e t h a t P i

w i ll b e d e c l a r e d t o b e d e a d l o c k e d i f a p r o b e c o m p u t a t i o n f o r P i b e g i ns w h e n t h e r e

e x i s ts a c y c l e o f p r o c e s s e s P i , Pj~I) . . . . Pj(m~, Pi , w h e r e e a c h p r o c e s s i n t h e

s e q u e n c e is d e p e n d e n t o n t h e n e x t . T h e p r o o f f o ll ow s f r o m t h e i n d u c t iv e h y p o t h -

e s is : d e p e n d e n t j ( k ) ( i ) w i l l b e s e t t o t r u e a n d Pj(k) w i l l s e n d a p r o b e t o t h e n e x t

p r o c e s s i n t h e s e q u e n c e f o r I _< k _< K , f o r a l l K . D e t a i l e d p r o o f s a r e g i v e n i n [ 1] .

I f d e s i re d , w h e n a c o n t r o l l e r d e t e c t s t h a t o n e o f it s c o n s t i t u e n t p r o c e s s e s i s

d e a d l o c k e d , i t c a n i n f o r m ( v i a t h e i r c o n t r o l l e r s ) a l l p r o c e s s e s w a i t i n g f o r t h e

d e a d l o c k e d p r o c e ss t h a t t h e y t o o a r e d e a d l o c k e d .

4. DEADLOCK DETECTION IN THE COMMUNICATION MODEL

W e n o w d e s c r i b e a d e a d l o c k d e t e c t i o n a lg o r i t h m f o r t h e c o m m u n i c a t i o n m o d e l

t h a t w i ll a ll o w a n i dl e p r o c e s s t o d e t e r m i n e w h e t h e r i t is d e a d l o c k e d .

A n i d l e p r o c e s s c a n d e t e r m i n e w h e t h e r i t is d e a d l o c k e d b y i n it i a ti n g a q u e r yc o m p u t a t i o n w h e n i t e n t e r s t h e i d l e s t a te . T h e q u e r y c o m p u t a t i o n is d i s t i n c t f r o m

t h e u n d e r l y in g c o m p u t a t i o n f o r w h i c h d e a d l o c k i s b e i n g d e t e c t e d . P r o c e s s e s m a y

e x c h a n g e m e s s a g e s f o r t h e q u e r y c o m p u t a t i o n e v e n i n t h e i d l e s t a te . T h i s is

b e c a u s e t h e s t a t e i s i d le o n l y i n r e f e r e n c e to t h e u n d e r l y i n g c o m p u t a t i o n . T h e

p r o c e s s w h i c h i n i t ia t e s a q u e r y c o m p u t a t i o n i s c a l le d t h e i n i t i a to r o f t h a t q u e r y

c o m p u t a t io n . S e v e r a l p r o ce s s e s m a y i n i t i a te q u e r y c o m p u t a t i o n s a n d t h e s a m e

p r o c e s s m a y i n i t ia t e q u e r y c o m p u t a t i o n s s e v e ra l t im e s .

T h e m e s s a g e s in a q u e r y c o m p u t a t i o n a r e o f t h e f o r m q u e r y ( i , m , j , k ) a n d

r e p ly ( i , m , j , k ) , d e n o t i n g t h a t t h e s e m e s s a g e s b e l o n g t o t h e m t h q u e r y c o m p u -

t a t i o n i n i t ia t e d b y p r o c e s s P i a n d a r e b e i n g s e n t f r o m P 1 t o Ph. P~, m, Pj , a n d P k

a r e c a l le d t h e i n i t ia t o r , s e q u e n c e n u m b e r , s e n d e r , a n d r e c e i v e r , r e s p e c t i v e l y .

T h e r e w i ll b e a t m o s t o n e m e s s a g e o f t h e f o r m q u e r y ( i , m , j , k ) ; t h e r e w i ll b e a t

m o s t o n e r e p l y m e s s a g e o f t h e f o r m r e p l y (i , m , k, j ) t o t h e q u e r y m e s s a g e q u e r y

( i , m , j , k ) .

T h e q u e r y c o m p u t a t i o n s h a v e t h e f o ll o w in g p r o p e r ti e s .

1. I f p r o c e s s P i is d e a d l o c k e d w h e n i t i n i t ia t e s i ts m t h q u e r y c o m p u t a t i o n , t h e n

i t w il l r e c e i v e r e p l y ( i , m , j , i ) c o r r e s p o n d i n g t o e v e r y q u e r y ( i , m , i , j ) t h a t i t se n t .

( S ee T h e o r e m 1 b e lo w . )

2 . I f t h e i n i t i a t o r , P~ , h a s r e c e i v e d r e p l y ( i , m , j , i ) c o r r e s p o n d i n g t o e v e r y

q u e r y ( i , m , i, j ) t h a t i t s e n t, t h e n i t i s d e a d l o c k e d . ( S e e T h e o r e m 2 b e l ow . )

A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l. 1 , N o . 2 , M a y 1 98 3.

Page 8: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 8/13

Dis t r i b u t e d De a d lo c k De t e c t i o n 1 5 1

I n o u r a l g o r i t h m e a c h p r o c e s s P k m a i n t a i n s f o u r a r r a y s o f l o c a l v a r i a b le s . T h e

i n d ic e s o f t h e a r r a y r a n g e o v e r a ll p r o c e s s e s i n t h e n e t w o r k . T h e l o c a l v a r i a b l e s

f o r P k k = 1 , 2 , 3 . . . a r e d e s c r i b e d b e l o w .

Def in i t ion 4 .1 T h e v a r i a b l e l a te s t ( i ) i s t h e l a r g e s t s e q u e n c e n u m b e r m i n a n y

q u e r y ( i , m , j , k ) s e n t o r r e c e i v e d b y P k . I n i t i a l l y , l a t e s t ( i ) = 0 , f o r a ll i.

Def in i t ion 4 .2 T h e v a r i a b l e e n g a g e r ( i ) , w h e r e i ~ k , i s t h e i d e n t i t y , s a y j , o f t h e

p r o c e s s w h i c h c a u s e d l a t e s t ( i ) t o b e s e t t o it s c u r r e n t v a l u e m b y s e n d i n g P k t h e

m e s s a g e q u e r y ( i , m , j , k ) . T h e i n i ti a l v a l u e i s a r b i t r a r y .

Def in i t ion 4 .3 T h e v a r i a b l e n u m ( i ) is t h e t o t a l n u m b e r o f m e s s a g e s o f t h e f o r m

q u e r y ( i , m , k , j ) s e n t b y P k , m i n u s t h e t o t a l n u m b e r o f m e s s a g e s o f t h e f o r m

r e p l y ( i , m , j , k ) r e c e i v e d b y P k, w h e r e m = l a t e s t ( i) a n d j is a r b i t r a r y . N o t e t h a t

n u m ( i ) = 0 m e a n s t h a t P k h a s r e c e i v e d r e p li e s to a l l q u e r i e s o f t h e f o r m (i, m , k ,

r ) t h a t P k s e n t , w h e r e m = l a t e s t ( i ) .

Def in i t ion 4 . 4 T h e v a r i a b l e w a i t ( i ) i s t rue i f a n d o n l y i f P k h a s b e e n i d lec o n t i n u o u s l y s i n c e la t e s t ( i ) w a s l a s t u p d a t e d . I n i t i a l l y w a i t ( i ) i s f a ls e , f o r al l i.

4 . 1 A l g o r i t h m

A n i d l e p r o c e s s i n i ti a t e s a q u e r y c o m p u t a t i o n b y s e n d i n g q u e r i e s t o p r o c e s s e s i n

i ts d e p e n d e n t s e t. T h e b a s i c i d e a is t h a t a n i d l e p r o c e s s o n r e c e i v i n g a q u e r y

s h o u l d p r o p a g a t e t h e q u e r y t o it s d e p e n d e n t s e t i f i t h a s n o t d o n e s o a l r e a d y .

T h u s , i f t h e r e is a s e q u e n c e o f p e r m a n e n t l y i d l e p r o c e s s e s P i . . . . . P j , s u c h t h a t

e a c h p r o c e s s i n t h e s e q u e n c e ( e x c e p t t h e f i rs t) i s i n th e d e p e n d e n t s e t o f t h e

p r e v i o u s p r o c e s s in t h e s e q u e n c e , a q u e r y i n i t i a te d b y P i w il l b e p r o p a g a t e d t o P i .

F o r t h e r e m a i n d e r o f t h i s d is c u s s io n w e c o n s i d e r th e a c t i o n t a k e n b y a p r o c e s sP k o n r e c e iv i n g a q u e r y o r r e p l y w i t h i n i t i a t o r i, s e q u e n c e n u m b e r m , a n d s e n d e r

j . L o c a l v a r i a b l e s la t e s t ( i) , e n g a g e r ( i ) , n u m ( i ) , a n d w a i t ( i ) r e f e r t o t h e v a r i a b l e s

o f p r o c e s s P k . I f m < l a t e s t (i ) , t h e n P k d i s c a rd s t h e m e s s a g e b e c a u s e ( b y D e f i n i t i o n

4 .1 ) P i m u s t h a v e i n i t ia t e d t h e q u e r y c o m p u t a t i o n w i t h s e q u e n c e n u m b e r l a t e s t (i )

a f t e r i t i n i ti a te d t h e m t h q u e r y c o m p u t a t i o n ; h e n c e P i c o u l d n o t h a v e b e e n

d e a d l o c k e d w h e n i t i n i t i a te d t h e m t h q u e r y c o m p u t a t i o n . I f w a i t ( i ) i s f a ls e w h e n

Pk r e c e i v e s t h e q u e r y / r e p l y , a n d i f m = l a t e s t( i ) , t h e n ( b y D e f i n i t i o n 4.4 ) P k h a s

b e e n i n t h e e x e c u t i n g s t a t e s in c e i t f i rs t p a r t i c i p a t e d i n t h e r u t h c o m p u t a t i o n

i n i t ia t e d b y P i. I n t h is c a se , w e c a n a s s e r t ( b y T h e o r e m 1 b e l ow ) t h a t P i w a s n o t

d e a d l o c k e d w h e n i t in i t i a te d i t s r u t h c o m p u t a t i o n ; h e n c e P k , d i sc a r d s t h e m e s s a g e .T h u s , P k d i s c a rd s a l l m e s s a g e s e x c e p t th o s e i n w h i c h r n > l a t e s t ( i ) o r t h o s e

r e c e i v e d w h e n w a i t ( i ) i s t r u e a n d m = l a t e s t (i ) .

I f m > l a t e s t ( i ) , t h e n b y D e f i n i t i o n s 4 .1 , 4 .2 , a n d 4 .4 , P k m u s t s e t l a t e s t ( i ) t o m ,

e n g a g e r ( i ) t o j ( w h e r e P 1 i s t h e s e n d e r ) , a n d w a i t ( i ) t o t r u e . I f P k r e c e i v e s a r e p l y

i n w h i c h m = l a t e s t ( i ) a n d w a i t ( i ) i s t r u e , t h e n ( b y D e f i n i t i o n 4 .3 ), P k m u s t

d e c r e m e n t n u m ( i ) b y 1.

W h e n P k r e c e i v e s a q u e r y i n w h i c h m > l a t e s t (i ) , i t p r o p a g a t e s t h e q u e r y t o a l l

p r o c e s s e s in it s d e p e n d e n t s e t , s e t s n u m ( i ) t o t h e n u m b e r o f p r o c e s s e s in t h e

d e p e n d e n t s e t ( b y D e f i n i t io n 4 .3 ), a n d u p d a t e s o t h e r l o c al v a r i a b l e s a s d i s c u s s e d

e a r li e r. W h e n P k in i t ia t e s a q u e r y c o m p u t a t i o n i t d o e s s o b y a c t i n g a s t h o u g h i t

h a d j u s t r e c e i v e d a q u e r y i n w h i c h m > l a t e s t ( k ) .

N e x t , w e d e r i v e t h e c o n d i t i o n s u n d e r w h i c h P k s e n d s r e p l i e s . I f w a i t ( i ) i s t r u e

w h e n P k re c e i v e s a q u e r y i n w h i c h m - - l a t e s t ( i) , i t r e p l i e s t o t h e q u e r y

A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l. 1 , N o . 2 , M a y 1 9 83 .

Page 9: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 9/13

152 K .M . Chandy , J . M is ra , and L . M. Haas

i m m e d i a t e l y . I f w a i t ( i ) i s f a ls e w h e n P k re c e i v e s a q u e r y i n w h i c h m = l a t e s t ( i ) ,

o r w a i t ( i) i s a r b i t r a r y a n d m < l a t e s t (i ) , t h e n P k d is c a r d s t h e q u e r y a n d never

r e p li e s t o th i s q u e r y . T h e i n t e r e s t i n g q u e s t i o n i s w h e n s h o u l d P k r e p l y t o a q u e r y

i n w h i c h m > l a t e s t ( i ) ? B y D e f i n i t io n s 4 .1 a n d 4 .2 , s u c h a q u e r y m u s t h a v e b e e n

s e n t b y e n g a g e r ( i ) . T h e a n s w e r t o t h i s q u e s t i o n i s d e r i v e d b y e x t e n d i n g t h e

c o n d i t i o n s in D i j k s t r a a n d S c h o l t e n [ 2]; P k r e p l i e s t o e n g a g e r ( i ) o n l y i f w a i t ( i ) i s

t r u e a n d n u m ( i ) h a s b e e n r e d u c e d t o z e r o ( i.e ., P k h a s r e c e i v e d r e p l i e s to a l l

q u e ri e s w i t h i n i t ia t o r P i a n d s e q u e n c e n u m b e r m t h a t i t s e n t, a n d P k h a s b e e n

c o n t i n u o u s l y i dl e s i n ce i t f i rs t p a r t i c i p a t e d i n t h i s q u e r y c o m p u t a t i o n ) . T h i s

s c h e m e f o r r e p l y i n g t o e n g a g e r s i s n e c e s s a r y f o r T h e o r e m 2 ( g i v e n b e l ow ) : i f t h e

i n i t ia t o r r e c e iv e s re p l i e s t o a l l t h e q u e r i e s i t s e n d s t o i t s d e p e n d e n t s e t, t h e n t h e

i n i t ia t o r is d e a d l o c k e d . T h e d e t a i l e d d e s c r i p t i o n o f t h e a l g o r i t h m i s g i v e n b e lo w .

F o r a n i d le p r o c e s s P i t o i n i ti a t e a q u e r y c o m p u t a t i o n :

b e g i nla tes t ( i ) := l a tes t ( i ) + 1 ; wa i t ( i ) = t ru e ;send query ( i , l a tes t ( i ) , i , j ) to a l l p rocesses P j inP i ' s d e p e n d e n t s e t S ; n u m ( i ) : = n u m b e r o f e l e m e n t s i n S

e n d

F o r a n e x e c u t i n g p r o c e s s P k : O n b e c o m i n g e x e c u t i n g , s e t w a i t ( i ) = false, f o r a l l

i . D i s c a r d a l l q u e r i e s a n d r e p l i e s r e c e i v e d w h i l e i n e x e c u t i n g s t a t e .

F o r a n i d le p r o c e s s P k , u p o n r e c e i v i n g q u e r y ( i , m , j , k ) :

i f m > l a t e s t ( i)t h e n b e g i n

la tes t ( i ) := m; engager ( i ) := j ; wa i t ( i ) := t rue ;f o r a ll p r o c e s s e s P r i n P k ' s d e p e n d e n t s e t Ssend query( i , m, k , r ) ;n u m ( i ) : = n u m b e r o f p r o c e s s e s i n S

e n d

e l s e i f w a i t ( i) a n d m = l a tes t ( i )t h e n send rep ly( i , m, k,j) to Pj

U p o n r e c e i v i n g re p l y ( i , m , r, k ) :

i f m = l a t e s t ( i ) a n d w a i t ( i )t h e n b e g i n

n u m ( i ) := n u m ( i ) - 1 ;i f n u m ( i ) = 0t h e n i f i = k

t h e n d e c l a r e P k d e a d l o c k e de l s e s e n d r e p l y ( i, m, k,j) to Pjw h e r e j = e n g a g e r ( i )

e n d

4 . 2 P r o o f s

T H E O R E M 1 . If the initiator of a query computation is deadlocked when it

initiates the computation, it will (eventually) declare itself deadlocked.

P RO O F. C o n s i d e r a s e t S o f p r o c e s s e s , i n c l u d i n g t h e i n i t i a t o r , w h i c h i s d e a d -

l o c k e d a t t h e i n s t a n t a t w h i c h t h e q u e r y c o m p u t a t i o n i s i n i t ia t e d . P r o c e s s e s i n S

A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l . 1 , N o . 2 , M a y 1 98 3.

Page 10: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 10/13

Distributed Deadlock Detection 153

c a n n o t c h a n g e t h e i r d e p e n d e n t s e t s a n d t h e r e a r e n o m e s s a g e s i n t r a n s i t b e t w e e n

p r o c e s s e s i n S . H e n c e t h e p r o b l e m i s e q u i v a l e n t t o t h a t c o n s i d e r e d b y D i j k s t r a

a n d S c h o l t e n [ 2] w h e r e " q u e r i e s " c o r r e s p o n d t o t h e i r " m e s s a g e s, " a n d t h e i r p r o o f

a p p l i e s h e r e . [ ]

I n t h e f o l l o w in g w e r e s t r i c t o u r a t t e n t i o n t o a s i n g le q u e r y c o m p u t a t i o n , s a y

t h e m t h i n i t i a te d b y p r o c e s s P i . T h u s q u e r i e s , r e p l i e s , e n g a g e r s , a n d s o f o r t h ,

r e f e r t o t h i s s p e ci fi c c o m p u t a t i o n .

LEMMA 1 . S u p p o s e a p r o c e s s P k s e n d s a r e p ly to i t s e n g a g e r a n d s u b s e q u e n t l y

b e c o m e s e x e c u t i n g a t s o m e t i m e , s a y t. T h e n t h e r e e x i s ts a p r o c e s s P r i n P k ' s

d e p e n d e n t s e t (w h e r e th e d e p e n d e n t s e t i s d e t e r m i n e d a t th e p o i n t a t w h i c h P k

r e p l ie s to it s e n g a g e r ) w h i c h r e c e i ve s a q u e r y a n d s u b s e q u e n t l y b e c o m e s e x e-

c u t i n g a t s o m e t ' < t .

P RO O F. I n o r d e r f o r P k t o r e p l y t o i t s e n g a g e r , i t m u s t h a v e r e c e i v e d r e p l i e sf r o m a ll p r o c e s s e s i n it s d e p e n d e n t s e t. I n o r d e r f o r P k t o b e c o m e e x e c u t i n g , it

m u s t h a v e r e c e i v e d a m e s s a g e f r o m s o m e p r o c e s s in it s d e p e n d e n t s e t, sa y P r .

S i n c e P k b e c a m e e x e c u t i n g a f t e r s e n d i n g t h e r e p l y t o i ts e n g a g e r , it m u s t h a v e

r e c e iv e d t h e m e s s a ge f r o m P r a f t e r t h e r e p l y f r o m P r ; h e n c e , P r m u s t h a v e s e n t

t h e m e s s a g e a f t e r t h e r e p l y . T h e r e f o r e , t h e s e q u e n c e o f e v e n t s m u s t b e a s f o ll o w s.

P ~ g e ts t h e q u e r y f r o m P k , r e p l i es t o it , b e c o m e s e x e c u t i n g , a n d s e n d s t h e m e s s a g e

t o P k c a u s i n g i t t o b e c o m e e x e cu t i n g . [ ]

T H E O R E M 2 . I f th e i n i t ia t o r o f a q u e r y c o m p u t a t i o n d e c l a r e s i t s e l f

" d e a d l o c k e d , " t h e n i t b e l o n g s to a d e a d l o c k e d s e t .

P RO O F. L e t S b e t h e s e t o f p r o c e s s e s i n c l u d i n g t h e i n i t i a t o r w h i c h r e c e i v e d

q u e r i e s d u r i n g t h is q u e r y c o m p u t a t i o n . W e w i ll s h o w t h a t S i s a d e a d l o c k e d s e t.

E v e r y p r o c e s s r e p l y in g t o i t s e n g ag e r i n th i s c o m p u t a t i o n m u s t h a v e r e c e i v e d

r e p l ie s f o r a ll q u e r i e s t h a t i t s e n t . F r o m t h i s f a ct , th e f o l lo w i n g i n d u c t i v e h y p o t h -

e s is c a n b e e s t a b li s h e d . I f t h e i n i t i a t o r d e c l a r e s i t s e l f d e a d l o c k e d , a r e p l y m u s t

h a v e b e e n r e c e i v e d t o t h e q t h q u e r y i n t h e c o m p u t a t i o n , f o r q = 1, 2 . . . .

T h e r e f o r e , e v e r y p r o c e s s in S r e p l ie s t o it s e n g a g e r in t h e c o m p u t a t i o n . H e n c e ,

f r o m L e m m a 1, i t f o ll o w s t h a t i f p r o c e s s P k in S b e c o m e s e x e c u t i n g a t t i m e t a f t e r

r e c e i v in g a q u e r y , t h e n s o m e p r o c e s s P j i n S b e c o m e s e x e c u t i n g a t t i m e t ' a f t e r

r e c e i v i n g a q u e r y , a n d t" < t. U s i n g t h i s i n d u c t i v e l y , it f o ll o w s t h a t n o p r o c e s s i nS c a n b e c o m e e x e c u t i n g a f t e r re c e i v i n g a q u e r y , a n d h e n c e S i s a d e a d l o c k e d

s e t . [ ]

T H E O R E M 3 . A t l e a s t o n e p r o c e s s i n e v e r y d e a d l o c k e d s e t w i l l r e p o r t

" d e a d l o c k e d " i f e v e ry p r o c e s s i n i t i a te s a n e w q u e r y c o m p u t a t i o n w h e n e v e r i t

b e c o m e s i d l e .

P RO OF. F r o m T h e o r e m 1, t h e l a s t p r o c e s s t o b e c o m e i d le in a d e a d l o c k e d s e t

w i ll r e p o r t " d e a d l o c k e d . " [ ]

A s i n t h e r e s o u r c e m o d e l , a n y p r o c e s s d e t e c t i n g d e a d l o c k c a n i n f o r m o t h e r st h a t i t is d e a d l o c k e d .

A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l. 1 , N o . 2 , M a y 1 9 83 .

Page 11: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 11/13

1 5 4 K . M . Ch a n d y , J . M i s ra , a n d L . M . Ha a s

4 . 3 E x a m p l e

T h e r e s o u r c e m o d e l i s s o si m p l e t h a t w e d o n o t g i ve a n e x a m p l e f o r it . W e d o g i ve

a n e x a m p l e f o r t h e c o m m u n i c a t i o n m o d e l . A m o r e e l a b o r a t e e x a m p l e is f o u n d i n

[ 6] . I n t h i s e x a m p l e , w e u s e s u b s c r i p t s t o d i s t i n g u i s h l o c a l v a r i a b l e s b e l o n g i n g t o

d i f f e r e n t p r o ce s se s . F o r i n s t a n c e, e n g a g e r / ( j ) i s t h e v a l u e o f e n g a g e r ( j ) i n p r o c es s

P i .C o n s i d e r a n e t w o r k c o n s i st i n g o f f o u r p r oc e s se s . T h e n e t w o r k ' s i n i t ia l s t a t e a n d

a p o s s i b le e x e c u t i o n s e q u e n c e i s g i v e n b e lo w .

I n i t i a l S t a t e

P r o c e s s 1 : i d l e , w a i t i n g f o r p r o c e s s 2 o r p r o c e s s 3

P r o c e s s 2 : i d l e , w a i t i n g f o r p r o c e s s 4

P r o c e s s 3 : i d l e , w a i t i n g f o r p r o c e s s 1 o r p r o c e s s 4

P r o c e s s 4 : e x e c u t i n g

E x e c u t i o n S e q u e n c eT i m e A c t i o n

1 P r o c e s s 1 i n i t i a t e s i t s f i r s t q u e r y c o m p u t a t i o n .

P r o c e s s 1 s e n d s q u e r y ( l , 1 , 1 , 2 ) a n d q u e r y ( l , 1 , 1 , 3 ).

2 P r o c e s s 2 r e c e i v e s q u e r y ( l , 1, 1 , 2 ) .

En g a g e r2 (1 ) : - - 1 .

P r o c e s s 2 s e n d s q u e r y ( l , 1 , 2 , 4 ) .

3 P r o c e s s 3 r e c e i v e s q u e r y ( l , 1 , 1, 3 ).

E n g a g e r a ( 1 ) : = 1 .

P r o c e s s 3 s e n d s q u e r y ( l , 1 , 3 , 1 ) a n d q u e r y ( l , 1 , 3 , 4 ) .4 P r o c e s s 4 s e n d s a m e s s a g e t o p r o c e s s 3 .

5 P r o c e s s 1 r e c e i v e s q u e r y ( l , 1 , 3 , 1 ).

P r o c e s s 1 s e n d s r e p l y ( i, 1 , 1 ,3 ) .

6 P r o c e s s 4 c h a n g e s s t a t e f r o m e x e c u t i n g t o i d l e a n d w a i t s f o r p r o c e s s 2 .

N o t e t h a t p r o c e ss e s 2 a n d 4 a r e n o w d e a d l o c k e d .

7 P r o c e s s 4 r e c e i v e s q u e r y ( l , 1 , 2 , 4 ) .

E n g a g e r 4 ( 1 ) : = 2; l a t e s t 4 ( 1 ) : = 1; w a i t 4 ( 1 ) : = t r u e .

P r o c e s s 4 s e n d s q u e r y ( l , 1 , 4 , 2) ; n um_ 4 (1) := 1 .

8 P r o c e s s 4 r e c e i v e s q u e r y ( l , 1 , 3 , 4 ) .

S in c e m = l a t e s t4 (1) a n d w a i t4 (1) = t ru e .P r o c e s s 4 s e n d s r e p l y ( l , 1 , 4 , 3 ) .

9 P r o c e s s 3 r e c e i v e s m e s s a g e f r o m p r o c e s s 4 ( s e n t a t t i m e 4 ).

P r o c e s s 3 b e c o m e s e x e c u t i n g , s e t s w a i t3 ( 1) : = f a l s e .

1 0 P r o c e s s 4 i n i t i a t e s i t s f i r s t q u e r y c o m p u t a t i o n .

P r o c e s s 4 s e n d s q u e r y (4 , 1 , 4 , 2 ); n u m4 (4) := 1 ;

la tes t4 (4 ) := 1 ; wa i t4 (4) := t ru e .

1 1 P r o c e s s 2 r e c e i v e s q u e r y ( l , 1 , 4 , 2 ) ( s e n t a t t i m e 7 ).

P r o c e s s 2 s e n d s r e p l y ( l , 1 , 2 , 4 ) .

1 2 P r o c e s s 3 r e c e i v e s r e p l y ( l , 1, 4 , 3 ) ( s e n t a t t i m e 8 ) .

P r o c e s s 3 i s e x e c u t i n g . W a i t3 (1 ) i s fa l s e .

T h u s p r o c e s s 3 w i ll n e v e r s e n d r e p l y ( l , 1, 3 , 1) a n d p r o c e s s 1 w i l l n o t

d e c l a r e i t s e l f d e a d l o c k e d .

A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l . 1 , N o . 2 , M a y 1 98 3.

Page 12: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 12/13

Distributed Deadlock Detection 155

1 3 P r o c e s s 2 r e c e i v e s q u e r y ( 4 , 1 , 4 , 2 ) ( s e n t a t t i m e 1 0) .

E n g a g e r 2 ( 4) : = 4 i ; w a i t 2 ( 4) : = t r u e .

P r o c e s s 2 s e n d s q u e r y ( 4 , 1 , 2 , 4 ) ; n u m 2 ( 4 ) : = 1 .

1 4 P r o c e s s 4 r e c e i v e s r e p l y ( l , 1 , 2 , 4 ) .

W a i t 4 (1 ) is t r u e a n d n o w n u n ~ (1 ) is 0; e n g a g e r 4 ( 1 ) = 2 .P r o c e s s 4 s e n d s r e p l y ( l , 1 , 4 , 2 ).

1 5 P r o c e s s 4 r e c e i v e s q u e r y ( 4 , 1 , 4 , 2 ). S i n c e la t e s t 4 ( 4) = 1 , i t s e n d s

rep ly(4 , 1 , 4 , 2 ) .

1 6 P r o c e s s 2 r e c e i v e s r e p l y ( 4 , 1, 4 , 2 ) . S i n c e w a i t 2 ( 4 ) = t r u e , i t r e d u c e s

n u m 2 ( 4) f r o m 1 t o 0 . S i n c e e n g a g e r 2 (4 ) = 4 , i t s e n d s r e p l y ( 4 , 1 , 2 , 4 ) .

1 7 P r o c e s s 4 r e c e i v e s r e p l y ( 4 , 1 , 2 , 4 ) . S i n c e w a i t 4 ( 4 ) = t r u e , i t r e d u c e s

n u m 4 (4 ) f r o m 1 t o 0 a n d d e c l a r e s i t s e l f d e a d l o c k e d .

5. NOTES ON THE ALGORITHMST w o a l g o r i t h m s h a v e b e e n p r o p o s e d f o r t h e d e t e c t i o n o f d e a d lo c k s . T h e f ir s t

a l g o r it h m , a p p l i c a b le t o r e s o u r c e d e a d l o c k s , is s im p l e r , i n v o l v in g o n l y o n e t y p e o f

m e s s a g e ( p r o b es ) f o r d e a d l o c k d e t e c t i o n . T h e s e c o n d a l g o r i t h m i s a p p l i c a b l e t o a

m o r e g e n e r a l c l as s o f p r o b l e m s a n d t h e r e f o r e i n v o l v e s t w o t y p e s o f m e s s a g e s

( q u e r y a n d r e p l y ) . T h e s e a l g o r i t h m s a r e e a s y t o i m p l e m e n t s i n c e in e i t h e r c a s e,

e a c h m e s s a g e ( p r ob e , q u e r y , a n d r e p l y ) is o f f i xe d l e n g t h a n d r e q u i r e s a f e w

s i m p l e c o m p u t a t i o n a l s t e p s .

T h e s e a l g o r i t h m s s e e m a t t r a c t i v e f o r r e a s o n s o f p e r f o r m a n c e a s w e l l a s co r -

r e ct n e ss , s in c e t h e o v e r h e a d o f d e a d lo c k d e t e c t i o n c o m p u t a t i o n s a n d t h e m e s s a g e

t r af f ic a s s o c i a te d w i t h d e a d l o c k d e t e c t i o n i s g e n e r a t e d p r i m a r i l y w h e n p r o c e s s e sa r e i d l e (i .e ., t h e y h a v e n o t h i n g t o d o a n d n o t h i n g t o s e n d ). F u r t h e r m o r e ,

e x e c u t i n g p r o c e s s e s n e e d o n l y d i s c ar d t h e m e s s a g e s a s s o c i a t e d w i t h a d e a d l o c k

d e t e c t i o n c o m p u t a t i o n . E v e r y s i ng le d e a d l o c k d e t e c t i o n c o m p u t a t i o n i n v o lv e s n o

m o r e t h a n e p r o b e s i n r e s o u r c e m o d e l s o r e q u e r i e s a n d r e p l ie s in c o m m u n i c a t i o n

m o d e l s , w h e r e e is t h e n u m b e r o f c o m m u n i c a t i n g p r o c e s s p a i rs i n t h e n e t w o r k . I n

t h e w o r s t ca s e, w h e r e t h e n e t w o r k o f N p r o c e s s e s is f u l ly c o n n e c t e d , e = N × ( N

- 1). N o r m a l l y , e , a n d h e n c e t h e n u m b e r o f t h e s e m e s s a g e s , w il l b e m u c h l es s.

F o r e x a m p l e , i n t h e c a s e w h e r e e a c h o f t h e N p r o c e s s e s h a s a d e p e n d e n t s e t o f

s ize k o r less , e _< k × N .

T o r e d u c e t h e n u m b e r o f d e a d l o c k d e t e c t i o n c o m p u t a t i o n s w h i c h a r e i n it ia t ed ,

a p r o c e s s m a y i n i t ia t e o n e o n l y if i t h a s b e e n i d le c o n t i n u o u s l y f o r s o m e t i m e T ,

w h e r e T is a p e r f o r m a n c e p a r a m e t e r . I f t h e p r o c e s s l e a v e s t h e i d le s t a t e b e f o r e T ,

w e h a v e a v o i d e d i n i t ia t in g s u c h a c o m p u t a t i o n . T i m e - o u t s m a y b e u s e d i n a

s i m i la r m a n n e r f o r p r o b e , q u e r y , a n d r e p l y p r o p a g a t i o n . N o t e t h a t s i n ce e v e r y

p r o c e s s c o u l d i n i t ia t e d e a d l o c k d e t e c t i o n c o m p u t a t i o n s o n e o r m o r e t i m e s , p r o p e r

c h o i c e o f T is cr i ti c a l i n r e d u c i n g t h e n u m b e r o f t h e s e c o m p u t a t i o n s . I s s u e s

r e l a t e d t o t h i s a r e d i s c u s s e d i n [ 5 ] .

W e c a n e n s u r e t h a t n o p r o c e s s h a s a b a c k l og o f a n u n b o u n d e d n u m b e r o f

q u e r i e s o r p r o b e s b y r e q u i r i n g a p r o c e s s t o r e c e i v e a c k n o w l e d g m e n t s t o e a r l i e r

q u e r i e s o r p r o b e s f r o m a s pe c if ic p r o c e s s b e f o r e s e n d i n g t h e n e x t q u e r y o r p r o b e

t o t h a t p r o c e ss .O u r a l g o r i t h m s r e q u i r e t h a t a ll p r o c e s s e s w h i c h a r e p e r m a n e n t l y i d le ( i n c lu d i n g

t e r m i n a t e d , f a il ed , o r a b o r t e d p r o c e s s e s ) r e p l y to q u e r i e s a n d p r o p a g a t e t h e p r o b e .

A C M T r a n s a c t i o n s o n C o m p u t e r S y s t e m s , V o l . 1 , N o . 2 , M a y 1 9 8 3 .

Page 13: Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

8/8/2019 Artigo - Dete¸c˜ao de Deadlock Distribuído Chandy-Misra-Haas

http://slidepdf.com/reader/full/artigo-detecao-de-deadlock-distribuido-chandy-misra-haas 13/13

1 5 6 K . M . C h a n d y , J . M i s r a , a n d L . M . H a a s

I f f a il u re p r e v e n t s s u c h a r e p l y / p r o b e f r o m b e i n g se n t , t h e f a i lu r e m u s t b e

d e t e c t e d b y o t h e r m e a n s a n d t h e r e p l y / p r o b e s e n t. O u r a l g o r it h m f u r t h e r r e q u i r e s

t h a t t h e c o m p u t a t i o n ( fo r w h i c h d e a d l o c k is b e i n g d e t e c t e d ) b e c o r r e ct . I n

p a r t ic u l a r, i f t h e d e p e n d e n t s e t o f a p r o c e s s i s m i s c a l c u l a te d , t h e d e a d l o c k

d e t e c t i o n a l g o r i th m m a y n o t f u n c ti o n .

ACKNOWLEDGMENTS

W e a r e p a r t i c u l a r l y g r a t e f u l t o E . W . D i j k s t r a a n d C . S . S c h o l t e n f o r t h e i r

e n c o u r a g e m e n t a n d a d v i c e . I n p a r ti c u l a r, t h e p r o o f o f T h e o r e m 2 w a s s u g g e s t e d

b y S c h o l te n . W e w e r e h e l p e d g r e a t l y b y c o m m e n t s f r o m G . A n d r e w s , N . F r a n c ez ,

C . A . R . H o a r e , A n i t a J o n e s , a n d F . S c h n e i de r . S p e c i a l t h a n k s t o t h e r e f e r e e s f o r

t h e i r c o m m e n t s .

REFERENCES1. CHANDY, K . M . , AND MISRA, J . A d i s t r i b u t e d a l g o r i t h m fo r d e t e c t i n g re s o u r c e d e a d l o c k s i n

d i s t r i b u t e d s y s t e m s . I n P r o c . A C M S I G A C T - S I G O P S S y ru p. P r i n c i p l e s o f D i s t r i b u te d C o m p u t i n g

( O t t a w a , C a n a d a , A u g u s t 1 8 - 2 0 , 19 82 ), A C M , N e w Y o r k , 1 98 2 , p p . 1 5 7 - 16 4 .

2 . D IJ K ST R A , n . w . , A ND S CH O LT E N, C . S . T e r m i n a t i o n d e t e c t i o n f o r d i f f u s i n g c o m p u t a t i o n s . In f .

Process . Le t t . 11 , 1 (Aug. 1980), 1-4.

3. GLIGOR, V.D ., AND SHATTUCK,S . H . D e a d l o c k d e t e c t i o n i n d i s t r i b u t e d s y s t e m s . I E E E T r a n s .

S o f tw . E n g . S E - 6 , 5 (Sept . 1980) , 435-440.

4 . G O LD MA N, B . D e a d l o c k d e t e c t i o n i n c o m p u t e r n e t w o r k s . T e c h . R e p . M I T - L C S - T R 1 8 5 , M a s s a -

c h u s e t t s I n s t i t u t e o f T e c h n o l o g y , C a m b r i d g e , M a s s. , S e p t . 1 97 7.

5 . G R AY , J . N . N o t e s o n d a t a b a s e o p e r a t i n g s y s te m s . I n O p e r a t i n g S y s t e m s : A n A d v a n c e d C o u r s e ,

v o l . 6 0 , L e c t u r e N o t e s i n C o m p u t e r S c i e n c e , S p r i n g e r - V e r l a g , N e w Y o r k 1 9 7 8 , p p . 3 9 3 - 4 8 1 .

6 . H AA S, L . M . T w o a p p r o a c h e s t o d e a d lo c k i n d i s t r i b u t e d s y s te m s . P h . d . d i s se r t a t i o n , C o m p u t e r

S c i e n c e D e p t . , U n i v . o f T e x a s a t A u s t i n , J u l y 1 98 1 .

7 . H O A R E, C . A .R . C o m m u n i c a t i n g s e q u e n t i a l p r o c e s s e s . C o m m u n . A C M 2 1 , 8 (Aug. 1978), 666-677.

8. ISLOOR, S.S. , AND MARSLAND, T . A . A n e f f e c ti v e ' o n - l i n e ' d e a d l o c k d e t e c t i o n t e c h n i q u e f o r

d i s tr i b u te d d a t a b a s e m a n a g e m e n t s y s t em s . I n P r o c. C O M P S A C 1 97 8, I E E E , N e w Y o r k , p p . 2 8 3 -

288.

9 . L AM P OR T, L . T i m e , c l o c k s, a n d t h e o r d e r i n g o f e v e n t s i n a d i s t r i b u t e d s y s t e m . C o m m u n . A C M

21 , 7 ( Ju ly 1978) , 558-565.

1 0. L O M ET , D . B . C o p i n g w i t h d e a d l o c k i n d i s t r i b u t e d s y s t e m s . R e s . R e p . R C 7 4 6 0 ( # 3 2 1 9 6 ) , I B M ,

T . J . W a t s o n R e s e a r c h C e n t e r , Y o r k t o w n H e i g h t s , N . Y . , D e c . 1 9 78 .

11 . MAHOUD,S.A., AND RIORDON,J . S . S o f t w a r e c o n t r o l l e d a c c e s s t o d i s t r i b u t e d d a t a b a s e s . I N F O R

15 , 1 (Feb. 1977), 22-36.

1 2. M E N A S C E, D . , AN D M U N T Z, R . L o c k i n g a n d d e a d l o c k d e t e c t i o n i n d i s t r i b u t e d d a t a b a s e s . I E E E

Tr a n s . S o f tw . E n g . S E - 5 , 3 (May 1979) , 195-202.1 3. M I S R A , J . , AN D C HA N DY , K . M . T e r m i n a t i o n d e t e c t i o n o f d if f u s i n g c o m p u t a t i o n s i n c o m m u n i -

c a t i n g s e q u e n t i a l p r o c e s s e s . A C M T r a n s . P r o g r a m . L a n g . S y s t . 4, 1 (Jan. 1982), 37-43.

14. OBERMARCK,R . D i s t r i b u t e d d e a d l o c k d e t e c t i o n a l g o r i t h m . A C M T r a n s . D a t a b a s e S y s t. 7, 2

( June 1982) , 187-208.

15 . CHANDY,K . M . , AN D M IS RA , J . D e a d l o c k a b s e n c e p r o o f s f o r n e t w o r k s o f c o m m u n i c a t i n g p r o -

cesses . In f . Process . Le t t . 9, 4 (N ov. 1979), 185-18 9.

R e c e i v e d M a y 1 98 1; r e v i s e d A u g u s t 1 98 2; a c c e p t e d N o v e m b e r 1 98 2

ACM Transactions on Computer Systems, Vo l. 1, No. 2, May 1983.