Académique Documents
Professionnel Documents
Culture Documents
F distributed algorithms
F hierarchical algorithms
1 2
another process nor the OS can force a process to release a u 2 kinds of (directed) edges:
resource F Request edge — from thread to resource — indicates the
n Circular wait — there must exist a set of waiting processes thread has requested the resource, and is waiting to acquire it
such that P0 is waiting for a resource held by P1, P1 is waiting F Assignment edge — from resource instance to thread —
for a resource held by P2, … Pn-1 is waiting for a resource held indicates the thread is holding the resource instance
by Pn, and Pn is waiting for a resource held P0
u When a request is made, a request edge is added
F When request is fulfilled, the request edge is transformed into
an assignment edge
F When process releases the resource, the assignment edge is
3 deleted 4
RAG with single resource instances RAG with multiple resource instances
r1 r2 r1 r2 r2
r1 r2 r1
p1 p2 p3 p1 p2 p3 p2 p3
p1 p2 p3 p1
r3 r4 r3 r4 r4
r3 r4 r3
n a cycle in RAG with single resource instances is necessary and n cycle does not indicate deadlock
sufficient for deadlock n knot – strongly connected subgraph (no sinks) with no outgoing edges
n a knot in RAG is necessary and sufficient for deadlock
5 6
Deadlock prevention and avoidance Deadlock detection
n Deadlock prevention — eliminate one of the 4 deadlock conditions n Deadlock detection and resolution — detect, then break the deadlock
u examples n detection
F acquire all resources before proceeding (no wait while hold) u issues
F allow preemption (eliminate 3d condition) F maintenance of WFG
F prioritize processes and assign resources in the order of F search of WFG for deadlocks
priorities (no circular wait) u requirements
u may be inefficient F progress – no undetected deadlocks
n Deadlock avoidance — consider each resource request, and only fulfill F safety – no false (phantom) deadlocks
those that will not lead to deadlock n resolution
u Stay in a safe state — a state with no deadlock where resource
u roll back one or more processes to break dependencies in WFG
requests can be granted in some order such that all processes will and resolve deadlocks
complete
u may be inefficient
F Must know resource requirements of all processes in advance
9 10
14