Chemistry Reference and  Research
           
 
Periodic Table
- standard table
- large table
 
Chemical Elements
- by name
- by symbol
- by atomic number
 
Chemical Properties
 
Chemical Reactions
 
Organic Chemistry
 
Branches of Chemistry
Analytical chemistry
Biochemistry
Computational Chemistry
Electrochemistry
Environmental chemistry
Geochemistry
Inorganic chemistry
Materials science
Medicinal chemistry
Nuclear chemistry
Organic chemistry
Pharmacology
Physical chemistry
Polymer chemistry
Supramolecular Chemistry
Thermochemistry

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:16:19
The contents of this article are licensed from Wikipedia.org under the GNU Free Documentation License. How to see transparent copy