cut o ff theorems for deadlocks and serializability
play

Cut-o ff theorems for deadlocks and serializability Lisbeth Fajstrup - PowerPoint PPT Presentation

Cut-o ff theorems for deadlocks and serializability Lisbeth Fajstrup Department of Mathematics Aalborg University ACAT in Bremen, 2013 Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 1 / 28 Cut-O ff


  1. Cut-o ff theorems for deadlocks and serializability Lisbeth Fajstrup Department of Mathematics Aalborg University ACAT in Bremen, 2013 Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 1 / 28

  2. Cut-O ff Theorems General Property P holds for all n 2 N if and only P holds for n  M Think of n as a dimension. Here: Given thread T , T n means n copies of T run in parallel. The property P is deadlock free in one theorem and serializable in the other. Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 2 / 28

  3. PV -programs - controlling concurrency through locks A set of shared resources R - memory, printers,... A capacity function κ : R ! N . PV programs p are defined by the grammar p ::= P a | V a | p . p | p | p | p + p | p ∗ P a is a request to access the resource a , if granted acces, lock it. V a releases the resource. A program without the parallel operator is a thread . Resource r may be accessed by at most κ ( r ) threads at a time. At a final point, the program has released all resources. At an initial point, no resources are locked Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 3 / 28

  4. Geometrically One thread is represented by a graph. n threads in parallel are represented by a product of n graphs with “holes” where a resource is locked above its capacity. T 1 = T 2 = Pa . Pb . Va . Pa . Vb . Va κ ⌘ 1 T 2 Va Vb A A Pa B Va Pb A A Pa T 1 Pa Pb Va Pa Vb Va Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 4 / 28

  5. An execution is a directed path T 2 Va Vb A A Pa B Va Pb A A Pa T 1 Pa Pb Va Pa Vb Va Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 5 / 28

  6. Deadlock - no directed paths leave the point T 2 Va Vb A A Pa B Va Pb A A Pa T 1 Pa Pb Va Pa Vb Va Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 6 / 28

  7. Definition A state x = ( x 1 , . . . , x n ) 2 T 1 ⇥ T 2 ⇥ · · · ⇥ Tn is a deadlock if The only dipaths starting in x are constant. x is reachable: There is a dipath from 0 to x x 6 = > - not all Ti have finished If x is a deadlock, then x i = > or x i = Pr ( i ) and κ ( r ( i )) other threads hold a lock on r ( i ) at x Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 7 / 28

  8. A cut-o ff theorem for deadlocks Theorem 1 Let T be a PV thread accessing resources R with capacity κ : R ! N . Let T n be n copies of T run in parallel. T n is deadlock free for all n if and only if T M is deadlock free, where M = Σ r ∈ R κ ( r ). Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 8 / 28

  9. The bound M is sharp. Theorem 2 Given R = { r 1 , . . . , r k } with capacity κ : R ! N , the thread T = Pr 1 Pr 2 Vr 1 Pr 3 Vr 2 . . . Pr k Vr k − 1 Pr 1 Vr k Vr 1 satisfies: There is a deadlock in T M (and hence for all n � M ) where M = Σ r ∈ R κ ( r ). There are no deadlocks in T n for n  M Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 9 / 28

  10. The bound M is sharp. Theorem 2 Given R = { r 1 , . . . , r k } with capacity κ : R ! N , the thread T = Pr 1 Pr 2 Vr 1 Pr 3 Vr 2 . . . Pr k Vr k − 1 Pr 1 Vr k Vr 1 satisfies: There is a deadlock in T M (and hence for all n � M ) where M = Σ r ∈ R κ ( r ). There are no deadlocks in T n for n  M Proof: The deadlock is x = ( x 1 , . . . , x 1 , x 2 , . . . , x 2 , . . . , x k . . . x k ) where for i 6 = 1, x i = Pr i and x i is repeated κ ( r i − 1 ) times. x 1 is the last Pr 1 and is repeated κ ( r k ) times. All resources r are locked κ ( r ) times. Hence x is a deadlock and 6 = > . (Need to check reachability and no deadlocks in lower dimensions) Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 9 / 28

  11. Example. When κ ⌘ 1 x = ( x 1 , x 2 , . . . , x k ) and M = k : T 1 requests r 1 and has a lock on r k Ti requests r i and has a lock on r i +1 There are no deadlocks in T n for n < M : If y is a deadlock, then there is a y i 1 = Pr ( i 1) and another y i 2 with a lock on r ( i 1), so y i 2 = Pr ( i 1 + 1) (or the last P ( r 1) if r ( i 1) = r k . Hence, y is a permutation of ( x , > , > , . . . , > ). Similarly for general κ . Still need to see that x is reachable. Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 10 / 28

  12. Example T = PaPbVaPcVbPaVcVa , κ ⌘ 1. T 3 has a deadlock at (6 , 2 , 4) T 2 Va Vc A A Pa C Vb Pc B Va Pb A A Pa T 1 Pa Pb Va Pc Vb Pa Vc Va Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 11 / 28

  13. x = ( x 1 , . . . , x 1 , x 2 , . . . , x 2 , . . . , x k . . . x k ) is reachable T = Pr 1 Pr 2 Vr 1 Pr 3 Vr 2 . . . Pr k Vr k − 1 Pr 1 Vr k Vr 1 a dipath from 0 to x is composed of the pieces: γ 0 : 0 ! ( x 1 , 0 ) serially - one coordinate at a time. OBS, now hold κ ( r k ) locks on r k Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 12 / 28

  14. x = ( x 1 , . . . , x 1 , x 2 , . . . , x 2 , . . . , x k . . . x k ) is reachable T = Pr 1 Pr 2 Vr 1 Pr 3 Vr 2 . . . Pr k Vr k − 1 Pr 1 Vr k Vr 1 a dipath from 0 to x is composed of the pieces: γ 0 : 0 ! ( x 1 , 0 ) serially - one coordinate at a time. OBS, now hold κ ( r k ) locks on r k γ 1 : ( x 1 , 0 ) ! ( x 1 , 0 , x k ) one coordinate at a time. Now also κ ( r k − 1 ) locks on r k − 1 Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 12 / 28

  15. x = ( x 1 , . . . , x 1 , x 2 , . . . , x 2 , . . . , x k . . . x k ) is reachable T = Pr 1 Pr 2 Vr 1 Pr 3 Vr 2 . . . Pr k Vr k − 1 Pr 1 Vr k Vr 1 a dipath from 0 to x is composed of the pieces: γ 0 : 0 ! ( x 1 , 0 ) serially - one coordinate at a time. OBS, now hold κ ( r k ) locks on r k γ 1 : ( x 1 , 0 ) ! ( x 1 , 0 , x k ) one coordinate at a time. Now also κ ( r k − 1 ) locks on r k − 1 γ j : ( x 1 , 0 , x k − j + 2 , . . . , x k ) ! ( x 1 , 0 , x k − j + 1 , . . . , x k ). Now κ ( r i ) locks on r k − j , . . . , r k . For j = 2 , . . . , k � 1. Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 12 / 28

  16. x = ( x 1 , . . . , x 1 , x 2 , . . . , x 2 , . . . , x k . . . x k ) is reachable T = Pr 1 Pr 2 Vr 1 Pr 3 Vr 2 . . . Pr k Vr k − 1 Pr 1 Vr k Vr 1 a dipath from 0 to x is composed of the pieces: γ 0 : 0 ! ( x 1 , 0 ) serially - one coordinate at a time. OBS, now hold κ ( r k ) locks on r k γ 1 : ( x 1 , 0 ) ! ( x 1 , 0 , x k ) one coordinate at a time. Now also κ ( r k − 1 ) locks on r k − 1 γ j : ( x 1 , 0 , x k − j + 2 , . . . , x k ) ! ( x 1 , 0 , x k − j + 1 , . . . , x k ). Now κ ( r i ) locks on r k − j , . . . , r k . For j = 2 , . . . , k � 1. Need: No resource is locked above its capacity along γ . Let ρ i ( y ) be the number of locks held on r i at y 2 T M . Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 12 / 28

  17. x = ( x 1 , . . . , x 1 , x 2 , . . . , x 2 , . . . , x k . . . x k ) is reachable T = Pr 1 Pr 2 Vr 1 Pr 3 Vr 2 . . . Pr k Vr k − 1 Pr 1 Vr k Vr 1 a dipath from 0 to x is composed of the pieces: γ 0 : 0 ! ( x 1 , 0 ) serially - one coordinate at a time. OBS, now hold κ ( r k ) locks on r k γ 1 : ( x 1 , 0 ) ! ( x 1 , 0 , x k ) one coordinate at a time. Now also κ ( r k − 1 ) locks on r k − 1 γ j : ( x 1 , 0 , x k − j + 2 , . . . , x k ) ! ( x 1 , 0 , x k − j + 1 , . . . , x k ). Now κ ( r i ) locks on r k − j , . . . , r k . For j = 2 , . . . , k � 1. Need: No resource is locked above its capacity along γ . Let ρ i ( y ) be the number of locks held on r i at y 2 T M . For γ 0 : ρ i ( γ 0 ( t ))  1 for i 6 = k ρ k ( γ 0 ( t ))  κ ( r k ). ρ i ( γ 1 ( t ))  1 for i 6 = k � 1 , k . ρ k ( γ 1 ( t )) = k . ρ k − 1 ( γ 1 ( t ))  κ ( r k − 1 ). ρ i ( γ j ( t ))  1 for i  k � j + 1. ρ i ( γ j ( t )) = κ ( r i ) for i � k � j + 2. ρ k − j +1 ( γ j ( t ))  κ ( r k − j +1 ). Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 12 / 28

  18. Proof of theorem 1 Theorem 1 Let T be a PV thread accessing resources R with capacity κ : R ! N . Let T n be n copies of T run in parallel. T n is deadlock free for all n if and only if T M is deadlock free, where M = Σ r ∈ R κ ( r ). Prove: If there is a deadlock in T n , then there is a deadlock in T M . Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 13 / 28

  19. Proof of theorem 1 Theorem 1 Let T be a PV thread accessing resources R with capacity κ : R ! N . Let T n be n copies of T run in parallel. T n is deadlock free for all n if and only if T M is deadlock free, where M = Σ r ∈ R κ ( r ). Prove: If there is a deadlock in T n , then there is a deadlock in T M . For n < M : Let x = ( x 1 , . . . , x n ) be a (reachable) deadlock in T n . I.e. x i = Pr j ( i ) and ρ j ( i ) ( x ) = κ ( r j ( i ) ) or x i = > . x = ( x 1 , . . . , x n , > , . . . , > ) 2 T M is a (reachable) deadlock in T M , Then ˜ since ρ i ( ˜ x ) = ρ i ( x ) for all i Lisbeth Fajstrup (AAU) Cut-o ff theorems for deadlocks and serializability July 2013 13 / 28

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend