[i] Total amount of resources of type (A, B, C)?
The Total Amount of Resources = Sum of Columns of Allocation + Available Resource
= [2 9 11] + [1 5 2] = [3 14 13]
[ii] What are the contents of the Need matrix?
Calculation of the Need Matrix
Need [i] = Max [i] - Allocation [I]
Need for P0: (0, 0, 1) – (0, 0 , 1) = (0, 0, 1)
Need for P1: (1, 7, 5) – (1, 0, 0) = (0, 7, 5)
Need for P2: (2, 3, 5) – (1, 3, 5) = (1, 0, 0)
Need for P3: (0, 6, 5) – (0, 6, 3) = (0, 0, 2)
Need Matrix looks like in the following manner:
[iii] Is the system in a safe state? Why?
Available Resources are Available = (1, 5, 2)
Now check if each type of resource request is available for each process or not
Step 1: For Process P0:
Need <= Available
0, 0, 1 <= 1, 5, 2 condition is True.
New available = available + Allocation
(1, 5, 2) + (0, 0, 1) => 1, 5, 3
Step 2: For Process P1:
Need <= Available
0, 7, 5 <= 1, 5, 3 condition is False.
Step 3: For Process P2:
Need <= Available
1, 0, 0 <= 1, 5, 3 condition is True.
New available = available + Allocation
(1, 5, 3) + (1, 3, 5) => 2, 8, 8
Step 4: For Process P3:
Need <= Available
0, 0, 2 <= 2, 8, 8 condition is True.
New available = available + Allocation
(2, 8, 8) + (0, 6, 5) => 2, 14, 13
Step 5: Now again check for Process P1:
Need <= Available
0, 7, 5 <= 2, 14, 13 condition is True.
New available = available + Allocation
(2, 14, 13) + (1, 0, 0) => 3, 14, 13
Hence, execute the banker's algorithm to find the safe state and the safe sequence like P0, P2, P3 and P1 for available resources (1, 5, 2)
Order of Safe Sequence = P0, P2, P3, P1
The system allocates all the needed resources to each process. So, we can say that the system is in a safe state.