Bankers Algorithm
Bankers Algorithm
Banker’s Algo
i)Find the need matrix.
ii)Is the system in a safe state? (safety algorithm)
iii)Can the request made by process P4 (3,3,0) be granted.
iv) Find the total count of resources.
Process Allocation Maximum Available Need(Max-Alloc) Work=Available (3,3,2)
A B C A B C A B C A B C
P0 0 1 0 7 5 3 3 3 2 7 4 3 Finish[i]=False i=0 to 4
P1 2 0 0 3 2 2 1 2 2
P2 3 0 2 9 0 2 6 0 0 Safe Sequence <P1,P3,P4,P0,P2>
P3 2 1 1 2 2 2 0 1 1
P4 0 0 2 4 3 3 4 3 1
Allocated 7 2 5
Available 3 3 2
Total 10 5 7
Need<=Work
P1 1 2 2 <=0 02 No P4 1 0 1 <=0 02 No
P2 6 0 0 <=0 02 No
2. The operating system consists of 3 resources. The number of instances of each resource type is 10,5,5.
The current allocation state is as shown below.
i)Is the system in safe state?
ii)Can the request made by process P4 (1,0,2) be granted.
iii)Can the request made by process P1 (3,0,2) be granted.
Process Allocation Maximum Available Need(Max-Alloc) Work=Available(3 3 2)
A B C A B C A B C A B C
P0 0 1 0 7 5 3 3(10-7) 3(5-2) 2(5-3) 7 4 3 Finish[i]=False i=0 to 4
P1 2 0 0 3 2 2 1 2 2
P2 3 0 2 9 0 2 6 0 0 <P1
P3 2 1 1 2 2 2 0 1 1
P4 0 0 0 4 3 3 4 3 3
7 2 3
Need<= Work
P0 7 4 3 <= 3 3 2 No
P1 1 2 2 <= 3 3 2 Yes
Finish[1]= True
Work = Work + Allocation
Work= 3 3 2 + 2 0 0 =>5 3 2