There are 3 rules for Safety Algorithm:
1. we calculate Available resources ( in a Matrix structure )
2. Need <=(less than and equal to) Available
3. Available = available + Allocation
now calculate need matrix here by this, Need = maximum - allocation
Need
A B C
7 4 3
1 2 2
6 0 0
0 1 1
4 3 1
$$\textbf{Need}\\ \begin{array}{|c|c|c|} \hline A & B & C \\ \hline 7 & 4 & 3 \\ \hline 1 & 2 & 2 \\ \hline 6 & 0 & 0 \\ \hline 0 & 1 & 1 \\ \hline 4 & 3 & 1 \\ \hline \end{array}$$
so for P0 Need is NOT less than available, it moves to P1 here need is ( 1,2,2) and available is (3,3,2)
so for P1, need < available , P1 is in safe sequence . <P1>
now ADD allocation of P1 into available ( 2,0,0 + 3,3,2 ) = ( 5,3,2 ) is our new Available . so P2 can not satisfy , P3 can satisfy ( 0 ,1,1 < 5,3,2 ) now safe sequence becomes < P1 , P3> , available is now (7,4,3)
P4 next satisfy, safe sequence becomes < P1 , P3, P4 > , available is now (7,4,5)
P2 comes again , as P2 have (6,0,0) which is less than (7,4,3) in P0 , now safe sequence becomes < P1 , P3, P4 , P2 > available is now (10,4,7)
P0 is left , it comes , safe sequence becomes < P1 , P3, P4 , P2 , P0 > available is (10, 5, 7 )
this way we proceed and final safe sequence becomes < P1 , P3, P4 , P2 , P0 > .