Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Distributed Deadlock: Nargish

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 23

Distributed Deadlock

Nargish.
Deadlock Problem
Deadlock is a situation where a set of process is blocked
waiting on an event that will never occur

Kansas Legislature: when two trains approach each other


at a crossing, both shall come to a full stop and neither
shall start up again until the other has gone.
Deadlock in Distributed System
 Deadlocks in systems are similar to deadlocks in single
processor systems, only worse. Distributed
-They are harder to avoid, prevent or even detect .
-They are hard to cure when tracked down because all relevant
information is scattered over many machines .

 In distributed systems, a process can request and release


resources (local or remote) in any order, which may not be
known a priori and a process can request some resources
while holding others

 If the sequence of the allocation of resources to processes


is not controlled in such environments, deadlocks can occur.
Deadlock in Distributed System
 The problem of deadlocks has been generally studied in distributed
systems under the following model:

 System has only reusable resources

 Only exclusive access to resources

 Only one copy of each resource

 States of a process: running or blocked

 Running state: process has all the resources

 Blocked state: waiting on one or more resource


Process States
 In the running state a process Diagram:-
has all the needed resource.

 In the blocked state, a Process


process is waiting to acquire
some resources.

 Deadlock is a situation in
which a set of processes is
Running
blocked waiting for other
process in the set to release
the resource Blocked
Deadlock Characterization
Deadlock can occur in four conditions hold simultaneously:-
 Mutual exclusion: only one process at a time can use a
resource.
 Hold and wait: a process holding resource(s) is waiting to
acquire additional resources held by other processes.
 No preemption: a resource can be released only voluntarily by
the process holding it upon its task completion.
 Circular wait: there exists a set {P0, P1, …, P0} of waiting
processes such that P0 is waiting for a resource that is held by P1, P1
is waiting for a resource that is held by P2, …, Pn–1 is waiting for a
resource that is held by Pn, and Pn is waiting for a resource that is held
by P0.
False Deadlock
 Detecting a nonexistent deadlock in distributed systems
has been referred to as false deadlock detection. This
correspondence shows that false deadlock will never
occur in a system of two-phase locking transactions.
Resource vs Communication
Deadlock
Two types of deadlocks have been discussed:

 Resource deadlock:-
• Processes can simultaneously wait for several resources and cannot
proceed until they have acquired all those resources
• A set of processes is resource-deadlock if each process in the set
requests resources held by another process in the set and it must
receive all of the requested resources before it can become unblocked
 Communication deadlock:-
• Processes wait to communicate with other processes among a set of
processes
• A waiting process can unblock on receiving a communication from any
one of these processes
• A set of processes is communication deadlocked if each process in the
set is waiting to communicate with another process in the set and no
process in the set ever initiates any further communication until it
receives the communication for which it is waiting
Resource Deadlock
 Resource Deadlock uses AND condition.
AND conditions:
 a process that requires resources for execution can
proceed when it has acquired all those resources.

 This AND request model allows high concurrency as


process can request several resource simultaneously
.
 Out degree of nodes in the WFG can be greater than one.

 A Deadlock in this model corresponding to a cycle in the


wait for graph.(provided there is only one copy of every
resource in the system).
Example: AND condition

P1 P3
P2

S1

P6 P4
P8
P5
P9
P7
P10
S2
S3a cycle but no knot No Deadlock in the OR model
There is
Communication Deadlock
 Communication Deadlock uses OR condition.
OR conditions:
 a process that requires resources for execution can proceed
when it has acquired one of those requested resources.

 This OR request model does not allows high concurrency as


AND model.

 .The present of a knot in the WFG is sufficient condition for a


Deadlock.

 A cycle in the WFG is not sufficient condition for deadlock.


(provided there is only one copy of every resource in the
system).
Example: OR condition

P3 P3
P1 P2 P4 P1 P2 P4

P5
P5
No No
Deadlock
deadlock Deadlock Deadlock
Resource Allocation Graph
 Process

 Resource Type with 4 instances

 Pi requests instance of Rj
Pi
R
 Pi is holding an instance of Rj j

The sequence of Request edge


Process’s recourse
utilization  Pi releases an instance of Rj Pi
Assignment edge
Pi
Rj
Resource-allocation graph

Deadlock No Deadlock
Resource Allocation Graph With A
Deadlock

There are two cycles found.


Resource Allocation Graph With A
Cycle But No Deadlock
 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.
Wait-For Graph

 In distributed systems, the system state can be


modeled or represented by a directed graph, called
a wait-for graph (WFG)

 In a WFG, nodes are processes and there is a


directed edge from node P1 to node P2 if P1 is
blocked and is waiting for P2 to release some
resource

 A system is deadlocked if and only if there is a


directed cycle or not (depending upon the
underlying model) in the WFG
Wait-For Graph

P1 P2

P4 P3

Deadlock occur
Deadlock Handling Strategies
 Deadlock Prevention: difficult to achieve.
 Deadlock Avoidance: before allocation, check for
possible deadlocks.
 Difficult as it needs global state info in each site (that handles
resources).

 Deadlock Detection: Find cycles. Focus of


discussion.
Deadlock Prevention
To achieve this method a process acquire all the needed resource
simultaniously.For this a process request a remote resource by sending a
request message to the site where the resource is located.
It has the following drawbacks:-
 It is inefficient as it decrease the system concurrency.

 A set of process can be deadlock in the resource acquiring


phase.

 In many system future resource requirements are


unpredictable.

 It is highly in efficient and impractical.


Deadlock Avoidance
A resource is allocated to a process if the resulting system is safe.

it has following drawback:-


 It requires to translate huge storage requirements
information's and extensive communication cost.

 The process of checking for a safe global state must be


mutually exclusive.

 Due to the large number of process and resources, it will


be computationally expensive to check for a safe state.
Deadlock Detection
The literature of deadlock handling in distributed system is highly focus
towards deadlock detection methods. It requires an examination of the
status of process resource interaction for the presence of cycle wait.

Deadlock Detection in distributed system has two favorable condition.


 Once a cycle is formed in the WFG it persists until it
detected and broken.

 Cycle detection can proceed concurrently with the normal


activities of a system.
Control Organizations
 Centralized Control:-
o A control site constructs wait-for graphs (WFGs) and checks
for directed cycles.
o WFG can be maintained continuously (or) built on-demand by
requesting WFGs from individual sites.

 Distributed Control:-
o WFG is spread over different sites. Any site can initiate the
deadlock detection process.

 Hierarchical Control:-
o Sites are arranged in a hierarchy.
o A site checks for cycles only in descendents.

B. Prabhakaran 23

You might also like