Banker's algorithm
Banker's algorithm
banker's algorithm is the deadlock avoidance algorithm. Banker's is named because the algorithm is modeled after a banker who makes loads from a pool of capital and receives payments that are returned to that pool.
Algorithm is check to see if granting the request leads to an unsafe state.If it does,the request is denied.If granting the request leads to a safe state,it is carried out.
The Dijkstra proposed an algorithm to regulate resources allocation to avoid deadlocks.The banker's algorithm is the best known of the avoidance method.
By using avoidance method,the system is always kept in a safe state.
It is easy to check if a deadlock is created by granting a request,deadlock analysis method is used for this.
Deadlock avoidance uses the worst-case analysis method to check for future deadlock.
Safe state:
There is at least one sequence of resources allocation to process that does not result in a deadlock.
System is in a safe state only if there exist a safe sequence .A safe state is not a deadlock state.
Deadlock state is an unsafe state.It does mean the system is in a deadlock.
As long as the state is safe,the resources manager can be guaranteed to avoid a deadlock.
If system remains in safe state after allocating resource then only OS allocates resources to process.
1.Allocation: Allocation is a table in which row represent process and column represents resources(R).
2.Max : max be the maximum number of resources that process requires during its execution.
Need:It is current claim of a process,where a process's claim is equal to its maximum need minus its current allocation.
Need= Max-Allocation
Available:Number of resources-sum of the allocation to all process
Weakness of Banker's algorithm
1) It requires that there be a fixed number of resources to allocate.
2) The algorithm requires that users state their maximum needs in advance.
3)Number of users must remain fixed.
4)The algorithm requires that the bankers grant all request within a finite time.
5)Algorithm requires that process returns all resources within a finite time.
Example of Banker's algorithm:
https://freecodingatoz.blogspot.com/2019/03/example-of-bankers-algorithm.html
https://freecodingatoz.blogspot.com/2019/03/example-of-bankers-algorithm.html
0 comments:
New comments are not allowed.