Bankers Algo-Atinen Lab
Bankers Algo-Atinen Lab
Bankers Algo-Atinen Lab
Processes A B C A B C A B C
P0 1 1 2 4 3 3 2 1 0
P1 2 1 2 3 2 2
P2 4 0 1 9 0 2
P3 0 2 0 7 5 3
P4 1 1 2 1 1 2
Requirements
1. calculate the content of the need matrix
2. check if the system is in a safe state
3. determine the total sum of each type of resource
Solution:
1. The content of the need matrix can be calculated by using the formula given below:
Need = Max - Allocation
Need
Processes A B C
P0 3 2 1
P1 1 1 0
P2 5 0 1
P3 7 3 3
P4 0 0 0
Safe sequence:
1. For process PO
Need = (3, 2, 1)
Available = (2, 1, 0)
Need <= Available = False
Therefore, the system will move to the next process.
2. For process P1
Need = (1, 1, 0)
Available = (2, 1, 0)
Need <= Available = True
Therefore, request of P1 is granted, if granted Available value will be changed according to the formula below:
Available = Available + Allocation
Available = (2, 1, 0) + (2, 1, 2)
New Available = (4, 2, 2)
3. For process P2
Need = (5, 0, 1)
Available = (4, 2, 2)
Need <= Available = False
Therefore, the system will move to the next process.
4. For process P3
Need = (7, 3, 3)
Available = (4, 2, 2)
Need <= Available = False
Therefore, the system will move to the next process.
5. For process P4
Need = (0, 0, 0)
Available = (4, 2, 2)
Need <= Available = True
Therefore, the request of P4 is granted. Then change the Available according to the formula below:
Available = Available + Allocation
Available = (4, 2, 2) + (1, 1, 2)
New Available = (5, 3, 4)
6. Now, check again the process of P2, which request was granted
Need = (5, 0 ,1)
Available = (5, 3, 4)
Need <= Available = True
Therefore, again request of P2 is granted. Since the request is granted, change the Available according to the formula:
Available = Available + Allocation
Available = (5, 3, 4) + (4, 0 ,1)
New Available = (9, 3, 5)
b) process P0
Need = (3, 2, 1)
Available = (9, 5, 5)
Need <= Available = True
Request of P0 is granted.
3) To determine the total sum of each type of resource, use the formula below:
Total amount of resources = sum of columns of allocation + available
Requirements
1. calculate the content of the need matrix
2. check if the system is in a safe state
3. determine the total sum of each type of resource
SOLUTION:
1. The content of the need matrix can be calculated by using the formula given below:
Need
Processes A B C
P0 2 1 2
P1 0 2 0
P2 6 -1 0
P3 5 3 2
P4 0 0 0
P5 2 1 0
1. For process PO
NEED= (2,1,2)
AVAILABLE=(1,1,0)
Need <= Available = False
Therefore, the system will move to the next process.
2. For process P1
NEED= (0,2,0)
AVAILABLE=(1,1,0)
Need <= Available = False
Therefore, the system will move to the next process.
3. For process P2
NEED= (6,-1,0)
AVAILABLE=(1,1,0)
Need <= Available = False
4. For process P3
NEED= (5,3,2)
AVAILABLE=(1,1,0)
Need <= Available = False
Therefore, the system will move to the next process.
5. For process P4
NEED= (0,0,0)
AVAILABLE=(1,1,0) Need <= Available = True
Therefore, request of P4 is granted, if granted Available value will be changed according to the formula below:
Available = Available + Allocation
Available = (1, 1, 0) + (2, 2, 1)
New Available = (3, 3, 1)
6. Now, check again the process of P0, which request was NOT granted
NEED= (2,1,2)
Available = (3,3,1)
Need <= Available = True
Therefore, request of P0 is granted, if granted Available value will be changed according to the formula below:
Available = (3, 3, 1) + (1, 2, 2)
New Available = (4, 5, 3)
7. Now, check again the process of P1, which request was NOT granted
NEED= (0,2,0)
Available = (4,5,3)
Need <= Available = True
Therefore, request of P1 is granted, if granted Available value will be changed according to the formula below:
Available = (4, 5, 3) + (2, 1, 2)
New Available = (6, 6, 5)
8. Now, check again the process of P2, which request was NOT granted
NEED= (6,-1,0)
Available = (6,6,5)
Need <= Available = True
Therefore, request of P2 is granted, if granted Available value will be changed according to the formula below:
Available = (6, 6, 5) + (3, 1, 2)
New Available = (9, 7, 7)
9. Now, check again the process of P3, which request was NOT granted
NEED= (5,3,2)
Available = (9,7,7)
Need <= Available = True
Therefore, request of P3 is granted, if granted Available value will be changed according to the formula below:
Available = (9, 7, 7) + (2, 2, 1)
New Available = (11, 9, 8)
Request of P5 is granted.
ormula below:
ormula below:
ormula below:
ormula below: