N3 | … | N |
where N
A = Available System Resources Table | A1 | A2 | A3 | … | A |
where
C = Tasks Resources Assigned Table | C11 | C12 | C13 | … | C1 |
C21 | C22 | … | C2 | ||
… | … | ||||
C | … | C | |||
D = Tasks Resources Demand Table | D11 | D12 | D13 | … | D1 |
D21 | D22 | … | D2 | ||
… | … | ||||
D | … | D |
For example in table C, there are C11 units of resource R1, C12 units of resource R2, and so on, which are allocated to task T1. Similarly, there are C21 units of resource R1, C22 units of resource R2, and so on, which are allocated to task T2. For example in table D, task T1 demands additional D11 units of resource R1, additional D12 units of resource R2, and so on, in order to complete execution.
The deadlock detection algorithm is as follows:
1. Find a row
2. Mark the row
3. If an incomplete row is present, return to step 1. Otherwise, no deadlock is in the system, and the algorithm terminates.
Step 1 of the algorithm looks for a task whose resource requirements can be satisfied. If such a task exists, the task can run to completion. Resources from the completed task are freed back into the resource pool, which step 2 does. The newly available resources can be used to meet the requirements of other tasks, which allow them to resume execution and run to completion.
When the algorithm terminates, the system is deadlocked if table T has incomplete rows. The incomplete