Numerical Solved by Banker’s Algorithm
Q2. Consider the table given below for a system, find the need matrix and the safety sequence, is the request from process P1(0, 1, 2) can be granted immediately.
Resource – 3 types
A – (10 instances)
B – (5 instances)
C – (7 instances)
Process  Allocation  Maximum  Available  Need  





Solution: Banker’s Algorithm
Step 1:
Safety for process P_{0}
need_{0} = (7, 4, 3)
If need_{0} ≤ Available
if [(7, 4, 3) ≤ (3, 3, 2)] (false)
Process P_{0} must wait.
Step 2:
Safety for process P_{0}
need_{1 }= (1, 2, 2)
if need_{i} ≤ Available
if [(1, 2, 2) ≤ (3, 3, 2)]
P_{i} will execute.
Available = Available + Allocation
= (3, 3, 2) + (2, 0, 0)
= (5, 3, 2)
Step 3:
Safety for process P_{2}
need_{2 }= (6, 0, 0)
if need_{2} ≤ Available
if [(6, 0, 0) ≤(5, 3, 2)] (false)
P_{3} will execute.
Available = Available + Allocation
= (5, 3, 2) + (2, 1, 1)
= (7, 4, 3)
Step 5:
Safety for process P_{4}
need_{4 }= (4, 3, 1)
If need_{4 }≤ Available
If [(4, 3, 1) ≤ (6, 4, 3)]
P_{4} will execute.
Available = Available + Allocation
= (7, 4, 3) + (0, 0, 2)
= (7, 4, 5)
Step 6:
Safety for process P_{0}
_{ }need_{0} = (7, 4, 3)
if need_{0} ≤ Available
if [(7, 4, 3) ≤ (7, 4, 5)]
P_{0} will execute.
Available = Available + Allocation
= (7, 4, 5) + (0, 1, 0)
= (7, 5, 5)
Step 7:
Safety for process P_{2}
need_{2} = (6, 0, 0)
if need_{2} ≤ Available
if [(6, 0, 0) ≤ (7, 5, 5)]
P_{2 }will execute.
Available = Available + Allocation
= (7, 5, 5) + (3, 0, 2)
= (10, 5, 7)
Safety Sequence = <P1, P3, P4, P0, P2>
Awesome explaination of banker’s algorithm..!
Anyone can understand this way..
Thanx a lot..
A1 solution thank you sir ………..
Thanks!!! Very simply and clearly put,