- The wait-for graph scheme is not applicable to a resource-allocation system with multiple instances of each resource type.
- We turn now to a deadlock-detection algorithm that is applicable to such a system. The algorithm employs several time-varying data structures:
- Available. A vector of length
indicates the number of available resources of each type.
- Allocation. An
matrix defines the number of resources of each type currently allocated to each process.
- Request. An
matrix indicates the current request of each process.
- If
equals
, then process
is requesting
more instances of resource type
.
- The detection. algorithm described here simply investigates every possible allocation sequence for the processes that remain to be completed.
- Let
and
be vectors of length
and
, respectively. Initialize
. For
, if
, then
; otherwise,
.
- Find an index
such that both
- a.
-
- b.
-
If no such
exists, go to step 4.
-
Go to step 2.
- If
, for some
, then the system is in a deadlocked state. Moreover, if
, then process
is deadlocked.
- Consider a system with five processes
through
and three resource types
,
, and
.
- Resource type
has seven instances,
- Resource type
has two instances,
- Resource type
has six instances.
- Suppose that, at time
, we have the following resource-allocation state:
|
Allocation |
Request |
Available |
 |
 |
 |
 |
 |
010 |
000 |
000 |
 |
200 |
202 |
|
 |
303 |
000 |
|
 |
211 |
100 |
|
 |
002 |
002 |
|
- If the algorithm is executed, it will be found that the sequence
results in
for all
.
- Suppose now that process
makes one additional request for an instance of type
.
- Although we can reclaim the resources held by process
, the number of available resources is not sufficient to fulfill the requests of the other processes. Thus, a deadlock exists, consisting of processes
, and
.
Cem Ozdogan
2011-02-14