Académique Documents
Professionnel Documents
Culture Documents
Ú m
Ú m
m m
Ú
R1
P1 P2
R2
Resource Allocation Graph
Vor example P1 and P2 are two processes, R1 and R2 are two
resources. P1 request the resource R1, R1 held by process P2, P2 request
the resource R2, R2 is held by P1, then both are entered into the waiting
state. There is no work progress for process P1 and P2, it is also a
Deadlock. Deadlock can be represented by Resource Allocation Graph.
R1 R2
P2 P3
P1
R1r
R3 R4
P1 R1 P2 R2 P3 R4 P2 R3
R1 R3
P3
P1 P2
ÚR1r
ÚR1r
R3 R4
Safe
Ú
This algorithm checks whether a state
is in safe state or not. This algorithm requires O(mXn2) operations.
The steps of algorithm are as follows:
a. Initialize Work : = Available and
Vinish [i ] = false for i= 1,2,3,««««««.n
b. Vind an i such that both
Vinish [i ] := false
Êeed [i ] <= work
If no such I exists, go to step d.
c. Work := Work + Allocation [i ]
Vinish [i ] := true
Go to step b.
d. If Vinish [i ] := true for all I, then the system is in a safe state.
Ú
: To satisfy the
request made by process Pi for resource following actions are
required:
a. If request [i ] <= Êeed [i ], go to step b else display error message.
b. If request [i ] <= Available, go to step c else Pi must wait until the
resources available.
c. Available : = Available ± Request [i ]
Allocation [i ] : = Allocation [i ] + Request [i ]
Êeed [i ] : = Êeed [i ] ± Request [i ]
If the resulting resource allocation state is in safe state, then
resources are allocated to Pi.
Õm m m
Detection mechanism of deadlocks for single instance of resource
type is different. We can detect the dead locks using wait for graph for
single instance resource type and detect using detection algorithm for
multiple instances of resource type.
Single instance of
resource type means, the system consisting of only one resource for
one type. We can detect this type of deadlocks with the help of wait for
graph. A wait for graph is a graph, it derived from µresource allocation
graph¶. It consisting of only processes as vertices instead of resources
and processes in resource allocation graph.
Consider the given figure. We represent a resource allocation
graph and the corresponding wait for graph. An edge from Pi to Pj in a
wait for graph implies that process Pi is waiting for process Pj to
release a resource that Pi needs. An edge Pi to Pj exists in a wait for
graph if and only if the corresponding resource allocation graph
contains two edges Pi to Rq and Rq to Pj for some resource Rq.
R1 R2
P2 P3
P1
R3 R4
P2 P3
P1
P2 R3 P1 P3 R4 P2