# Explain Banker’s Algorithm

**Q1. Explain Banker’s Algorithm.**

**Ans.** Following are the points related to Banker’s Algorithm:

- For multiple instance.
- Each process must have maximum use.
- When a process requests a resource, it may have to wait.
- When a process gets all its resources, it must return them in a finite amount of time.

**Data Structures for Banker’s Algorithm**

Let n=number of processes and

m=number of resource type.

**Available**

Vector of length m.

If available [j]=k,

there are k instances of resource type Rj available.

**Max**

n x m matrix

If max [i,j]=k,

then process Pi may request almost k instance of resource type Rj.

**Allocation**

n x m matrix

If allocation [i,j]=k,

than Pi is currently allocated k instances of resource Rj.

**Need**

n x m matrix

If need [i,j]=k,

then Pi may need k more instances of Rj to complete its task.

Need [i,j]=Max [i,j] – allocation [i,j]