It's a Resource allocation and deadlock avoidance algorithm. which states Maximum number of instances of each resource type the process can claim.
DEFINITION:
“The Banker’s algorithm is a resource allocation and deadlock avoidance algorithm developed by Edsger Dijkstra that tests for safety by simulating the allocation of predetermined maximum possible amounts of all resources, and then makes a “s-state” check to test for possible deadlock conditions for all other pending activities, before deciding whether allocation should be allowed to continue” – source Wikipedia.
WHY THE NAME BANKER'S?
“Like other algorithms, the Banker’s algorithm has some limitations when implemented. Specifically, it needs to know how much of each resource a process could possibly request. In most systems, this information is unavailable, making it impossible to implement the Banker’s algorithm.“ – source Wikipedia
DESIGN
“The Banker’s algorithm is run by the operating system whenever a process requests resources. The algorithm avoids deadlock by denying or postponing the request if it determines that accepting the request could put the system in an unsafe state (one where deadlock could occur). When a new process enters a system, it must declare the maximum number of instances of each resource type that may not exceed the total number of resources in the system. Also, when a process gets all its requested resources it must return them in a finite amount of time” – source Wikipedia
LIMITATION
“Like other algorithms, the Banker’s algorithm has some limitations when implemented. Specifically, it needs to know how much of each resource a process could possibly request. In most systems, this information is unavailable, making it impossible to implement the Banker’s algorithm.“ – source Wikipedia
Following Links can be referenced:
Sample Output
Enter the number of resources:4
Enter the number of processes:5
Enter Claim Vector:8 5 9 7
Enter Allocated Resource Table:
2 0 1 1
0 1 2 1
4 0 0 3
0 2 1 0
1 0 3 0
Enter Maximum Claim table:
3 2 1 4
0 2 5 2
5 1 0 5
1 5 3 0
3 0 3 3
The Claim Vector is: 8 5 9 7
The Allocated Resource Table:
2 0 1 1
0 1 2 1
4 0 0 3
0 2 1 0
1 0 3 0
The Maximum Claim Table:
3 2 1 4
0 2 5 2
5 1 0 5
1 5 3 0
3 0 3 3
Allocated resources: 7 3 7 5
Available resources: 1 2 2 2
Process3 is executing
The process is in safe state
Available vector: 5 2 2 5
Process1 is executing
The process is in safe state
Available vector: 7 2 3 6
Process2 is executing
The process is in safe state
Available vector: 7 3 5 7
Process4 is executing
The process is in safe state
Available vector: 7 5 6 7
Process5 is executing
The process is in safe state
Available vector: 8 5 9 7