deadlocks detection
play

Deadlocks Detection Course: Distributed Computing Faculty: Dr. - PowerPoint PPT Presentation

Deadlocks Detection Course: Distributed Computing Faculty: Dr. Rajendra Prasath Spring 2019 About this topic This course covers various concepts in Mutual Exclusion in Distributed Systems. We will also focus on different types of distributed


  1. Deadlocks Detection Course: Distributed Computing Faculty: Dr. Rajendra Prasath Spring 2019

  2. About this topic This course covers various concepts in Mutual Exclusion in Distributed Systems. We will also focus on different types of distributed mutual exclusion algorithms in distributed contexts and their analysis 2 Rajendra, IIIT Sri City

  3. RECAP What did you learn so far? What did you learn so far? è Challenges in Message Passing systems è Distributed Sorting è Space-Time Diagram è Partial Ordering / Causal Ordering è Concurrent Events è Local Clocks and Vector Clocks è Distributed Snapshots è Termination Detection è Topology Abstraction and Overlays è Leader Election Problem in Rings è Message Ordering / Group Communications è Distributed Mutual Exclusion Algorithms 3 Rajendra, IIIT Sri City

  4. Topics to focus on opics to focus on … For End Semester è Distributed Mutual Exclusion è Deadlock Detection è Check pointing and rollback recovery è Self-Stabilization è Distributed Consensus è Reasoning with Knowledge è Peer – to – peer computing and Overlays è Authentication in Distributed Systems 4 Rajendra, IIIT Sri City

  5. Deadlocks Let us explore deadlock detection, prevention and avoidance algorithms in distributed systems 5 Rajendra, IIIT Sri City

  6. Distributed Mutual Exclusion (r Distributed Mutual Exclusion (recap) ecap) è No Deadlocks – No processes should be permanently blocked, waiting for messages (Resources) from other sites è No starvation – no site should have to wait indefinitely to enter its critical section, while other sites are executing the CS more than once è Fairness - requests honored in the order they are made. This means processes have to be able to agree on the order of events. (Fairness prevents starvation) è Fault Tolerance – the algorithm is able to survive a failure at one or more sites 6 Rajendra, IIIT Sri City

  7. Deadlock Deadlock – A Simple Example Simple Example è Vehicular Traffic at a signal Deadlock Possible Deadlocked 7 Rajendra, IIIT Sri City

  8. Deadlock Deadlock – Another Example Another Example è Vehicular Traffic – Another Scenario 8 Rajendra, IIIT Sri City

  9. Deadlock Deadlock – Illustr Illustrated ated è Vehicular Traffic – A real-time scenario 9 Rajendra, IIIT Sri City

  10. Dining Philosophers’ P Dining Philosophers’ Problem oblem è Suggest a Simple è Each philosopher must Solution ?? alternately think and eat è A philosopher can only eat when they have both left and right forks è Problem: How to design a discipline of behavior (a concurrent algorithm) such that no philosopher will starve? 10 Rajendra, IIIT Sri City

  11. Dining Philosophers’ P Dining Philosophers’ Problem oblem è Deadlock-Free è Soln - 1: Forks will be numbered 1 through 5 Solutions !! and each philosopher will always pick up the lower-numbered fork first, and then the higher- numbered fork è Soln - 2: Use Arbitrator (waiter) to grant permission to pick up both forks 11 Rajendra, IIIT Sri City

  12. Deadlocks in Distributed Deadlocks in Distributed Sytems Sytems Definition è A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set è No process can progress in the system è Competing processes may WAIT indefinitely for resources è How do we manage resources among the competing tasks efficiently? 12 Rajendra, IIIT Sri City

  13. Deadlocks Deadlocks – A few mor few more examples e examples Tape Drives è Assume that a system has two Tape Drives è There are two processes P 1 and P 2 each hold one drive è Now each process needs access to another tape drive è P 1 does not get access to the resource held by P 2 and vice versa. è This implies DEADLOCK … neither P 1 nor P 2 succeeds in its attempt 13 Rajendra, IIIT Sri City

  14. Deadlocks Deadlocks – A few mor few more examples e examples Semaphores è Semaphores A and B P 1 P 2 wait (A) wait(B) OR wait (B) wait(A) è This implies DEADLOCK … neither P 1 nor P 2 succeeds in its attempt 14 Rajendra, IIIT Sri City

  15. Deadlock Deadlock – Char Characterization acterization è Mutual exclusion - only one process at a time can use a resource è Hold and wait - a process holding at least one resource is waiting to acquire additional resources held by other processes. è No preemption - a resource can be released only voluntarily by the process holding it, after that process has completed its task. è Circular wait - there exists a set { P 0 , P 1 , Ÿ Ÿ Ÿ , P 0 } of waiting processes such that P i is waiting for a resource that is held by P j (mod n) where n is the total number of resources 15 Rajendra, IIIT Sri City

  16. System Model System Model è Resource types: R 1 , R 2 , . . . , R m è CPU cycles, memory space, I/O devices è Each resource type R i has W i instances. è Each process utilizes a resource as follows: è REQUEST è USE (Critical Section) è RELEASE è Recall - Distributed Exclusion Algorithms 16 Rajendra, IIIT Sri City

  17. Resour Resource ce Allocation Gr Allocation Graph (RA aph (RAG) G) è A set of vertices V and a set of edges E è V is partitioned into two types: Set consisting of all processes è P = {P 1 , P 2 , …, P n } Set consisting of all resource types è R = {R 1 , R 2 , …, R m } è request edge – directed edge P i → R j è assignment edge – directed edge R j → P i 17 Rajendra, IIIT Sri City

  18. Resour Resource ce Allocation Gr Allocation Graph aph (contd contd) è Process è Resource type with 4 instances è P i requests an instance of R j P i R j è P i is holding an instance of R j P i R j 18 Rajendra, IIIT Sri City

  19. RA RAG G – An example An example è Look at this graph è Resources: è R 1 – 1 unit è R 2 – 2 units è R 3 – 1 unit è R 4 – 3 units è Requests: è P 1 , P 2 , P 3 19 Rajendra, IIIT Sri City

  20. RA RAG with a Deadlock G with a Deadlock è Look at this graph è P 1 needs R 1 which in turn used by P 2 and P 2 is requesting R 3 which is currently being accessed by P 3 and P 3 needs R 2 which is being locked by P 1 and P 2 è This implies Deadlock 20 Rajendra, IIIT Sri City

  21. RA RAG with a cycle but NO Deadlock G with a cycle but NO Deadlock è Look at this graph è P 2 and P 4 may release the resource R 3 in finite time as they do not depend on other competing processes è There exists a cycle but may not be a deadlock !! 21 Rajendra, IIIT Sri City

  22. Basic F Basic Facts acts è If graph contains no cycles ⇒ no deadlock è If graph contains a cycle ⇒ è if only one instance per resource type, then deadlock è if several instances per resource type, possibility of deadlock 22 Rajendra, IIIT Sri City

  23. How to handle Deadlocks? How to handle Deadlocks? è Ensure that the system will never enter a deadlock state è Deadlock Prevention – Stop before it happens! è Deadlock Avoidance – Precautions !! è Deadlock Detection – How to overcome? è Allow the system to enter a deadlock state and then recover è Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems, including UNIX 23 Rajendra, IIIT Sri City

  24. Deadlock P Deadlock Prevention evention 4 Conditions to occur Deadlocks: è Mutual Exclusion – Exclusive access – when a process accesses a resource, it is granted exclusive use of that resource è Hold and wait – a process is allowed to hold onto some resources while waiting for other resources è No preemption – a process cannot preempt or take away the resources held by another process è Cyclical wait – There is a circular chain of waiting processes, each waiting for a resource held by the next process in the chain 24 Rajendra, IIIT Sri City

  25. Deadlock Deadlock Avoidance Avoidance Requires that the system has some additional a priori information available è Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need è Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes è The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition 25 Rajendra, IIIT Sri City

  26. Safe State Safe State When a process requests an available resource, system è must decide whether the allocation immediate leaves the system in a Safe State? Safe State? System is in Safe State Safe State if there exists a sequence <P 1 , P 2 , è …, P n > of ALL processes such that for each P i , the resources that P i can still request, can be satisfied by available resources + resources held by all P j , j < I If P i resource needs are not immediately available, è then P i can wait until all P j have finished When P j is finished, P i can obtain needed resources, è execute, return allocated resources, and terminate When P i terminates, P i +1 can get resources and so on è 26 Rajendra, IIIT Sri City

  27. Basic F Basic Facts acts è If a system is in safe state ⇒ no deadlocks è If a system is in unsafe state ⇒ possibility of deadlock è Avoidance ⇒ ensure that a system will never enter an unsafe state 27 Rajendra, IIIT Sri City

  28. Safe / Unsafe / Deadlock State Safe / Unsafe / Deadlock State è Illustration of safe, unsafe and deadlock state 28 Rajendra, IIIT Sri City

  29. 29 Rajendra, IIIT Sri City

Recommend


More recommend