In: Computer Science
Banker's algorithm:
The Banker's algorithm is a resource allocation and deadlock avoidance algorithm that tests for safety by simulating the allocation for predetermined maximum possible amounts of all resources, then makes a "S-state" check to test for possible activities, before deciding whether allocation should be allowed to continue.
WORKING PROCEDURE:
It checks if allocation of any resource will lead to deadlock or not,or is it safe to allocate a resource to a process and if not then resource is not allocated to that process. Banker's algorithm is generally used to find if a safe sequence exists or not. But here we will determine the total number of safe sequences and print all the safe sequences. Determining a safe sequence (even if there is only 1) will assure that system will not go into deadlock.
FUNCTIONS & POINTERS :
The important notations used in Banker's algorithm are
Available
Max
Allocation
Need
Let 'n' be the number of processes in the system and 'm' be the number of resource types.
1.Available:
2.Max :
3.Allocation:
4.Need:
Allocationi specifies the resources currently allocated to process Pi
and Needi specifispecifies the additional resources that process Pi may still request to complete its task.
Banker's algorithm consists of Safety algorithm and Resource request algorithm.