Maths encyclopedia and lessons  
Search

Mathematics Encyclopedia and Lessons

 
     
 

Lessons

Popular
Subjects

algebra
arithmetic
calculus
equations
geometry
differential equations
trigonometry
number theory
probability theory
more
 

References

applied mathematics
mathematical games
mathematicians
more
 
 

Banker's algorithm

The banker's algorithm is used to avoid deadlocks in resource scheduling. To use it, you have to think like a bank. Basically, you have to put each state into a separate queue. You then use four arrays: available, allocation, maximum, and need. In terms of little O notation, the banker's algorithm is o(n2m), where n is the processes and m is the resources.

Working of banker's algorithm:

Four arrays are used to store the following information in them:

  1. Available [m]: This array stores the total number of resources, available or allotted both.
  2. Allocation [m \times n]: or Current Allocation. This array stores the current allocation to the processes.
  3. Maximum Allocation [m \times n]: This array stores the maximum allocation of each process.
  4. Need Allocation [m \times n]: This array is calculated on the basis of the matrix subtraction of Maximum Allocation with Current Allocation.

A system is in a safe state if there is an order in which the resource requests for all processes can eventually be granted, preventing deadlock. The Banker's algorithm works by finding one such state. If no safe state can be found, the system is at risk of deadlock and it is not in a safe state.


Algorithm Logic

The algorith works on providing resources to the lowest requirement - deadlock process first. Once the process has expired, the resources free up for the next process and so on.

See also

Banker's rounding

01-04-2007 01:18:14
The contents of this article are licensed from Wikipedia.org
under the GNU Free Documentation License. How to see transparent copy