Calculate the Need of each resource by using the need formula and draw the Need Matrix.
Suppose a system has resource type A with 18 instances and 5 processes and
the current system state is shown in the following table.
Process | Max Need | Allocated |
P0 | 12 | 5 |
P1 | 6 | 4 |
P2 | 14 | 4 |
P3 | 16 | 3 |
P4 | 8 | 2 |
Calculate the Need of each resource by using the need
formula and draw the Need Matrix.
Solution:
The need of each resource for a process can be calculated by using the following formula:
Needi = Maxi – Allocatedi
Where: i = process number Maxi = maximum need of a resource for process i Allocatedi = allocated resource for process i
Based on the given information, we can calculate the need of each resource for each process as follows:
Process Max Need Allocated Need
P0 = 12 - 5 = 7
P1 = 6 - 4 = 2
P2 = 14 - 4 = 10
P3 = 16 - 3 = 13
P4 = 8 - 2 = 6
The Need Matrix can be represented as follows:
P0 | P1 | P2 | P3 | P4 | |
A | 7 | 2 | 10 | 13 | 6 |
It's worth mentioning that, the Need Matrix represents the remaining need of each resource for each process.
No comments