Banker's algorithm


### It is Deadlock Avoidance itself
**Define a set of vectors and matrices that characterize the current state of all resources and processes**
> Each process must a priori claim maximum use




# DataStructure
- n - process number, m resource **type **number.
- **Available** : one dimension array of length m - store available resources number by resource **type**
- **Max** (require to retire process): two dimension array of m x n - process i require j type and express it by max[i,j]
- **Allocation** : two dimension array of m x n - how much allocated - allocation[i,j]
- **Need** : two dimension array of m x n - **(Need = Max - Allocation) how much more need**

### Banker's algorithm is function of input **Request**
Request_i : one dimension array of length m - request vector for process Pi
![](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F7b38698d-432a-474a-bdde-51b3874c093e%2FUntitled.png?table=block&id=48f55dad-e108-4519-8bff-2aea677cb0f5&cache=v2)
# Safety Algorithm
**Work(copy of Available) **and **Finish(initialized false for all process) **be vectors of length m and n, respectively → fine sequence of execution
### Result is no → process must wait

## Difference
All tow algorithm is Deterministic Algorithm but Banker's is determine for Allocation 
Detection is determine of checking deadlock
- Banker's Algorithm is virtual verification of unassigned resource by simulation
- Detection Algorithm is check stage is safe or not



