Unit 4_Deadlock Handling
Unit 4_Deadlock Handling
Deadlock Management
Outline
Deadlock Management
Deadlock Prevention
Deadlock Avoidance
Deadlock Detection & Resolution
Centralized Deadlock Detection
Hierarchical Deadlock Detection
Distributed Deadlock Detection
Deadlock Management
Deadlock
is a permanent phenomenon. If one exists in a system, it will not go away
unless outside intervention takes place. This outside interference may
come from the user, the system operator, or the software system (the
operating system or the distributed DBMS). A deadlock can occur
because transactions wait for one another and occurs when the WFG
contains a cycle.
Deadlock: Necessary Conditions
‰For a deadlock to occur, each of the following four conditions must hold.
Mutual Exclusion
Hold and Wait
No Preemption
™Circular Wait
Deadlock Management
wait-for graph(WFG)
A useful tool in analyzing deadlocks is a wait-for graph (WFG). A WFG is a directed
graph that represents the wait-for relationship among transactions. The nodes of
this graph represent the concurrent transactions in the system. An edge Ti ! Tj
exists in the WFG if transaction Ti is waiting for Tj to release a lock on some
entity .
We should indicate that the formation of the WFG is more complicated in distributed
systems, since two transactions that participate in a deadlock condition may be
running at different sites. We call this situation a
global deadlock. In distributed systems, then, it is not sufficient that each local
distributed DBMS form a
local wait-for graph (LWFG) at each site; it is also necessary to form a global wait-for
graph (GWFG), which is the union of all the LWFGs.
Deadlock Management
Difference between LWFG and GWFG
Assume T1 and T2 run at site 1, T3 and T4 run at site 2. Also assume T3 waits for a lock
held by T4 which waits for a lock held by T1 which waits for a lock held by T2
which, in turn, waits for a lock held by T3.
WPUND-WAIT algorithms
If Ti requests a lock on a data item which is already locked by Tj , then Ti is permitted to wait
iff ts(Ti)>ts(Tj). If ts(Ti)<ts(Tj), then Tj is aborted and the lock is granted to Ti.