Explain Banker’s Algorithm

Q1. Explain Banker’s Algorithm.

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

  1. For multiple instance.
  2. Each process must have maximum use.
  3. When a process requests a resource, it may have to wait.
  4. 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.

  1. Available

Vector of length m.

If available [j]=k,

there are k instances of resource type Rj available.

  1. Max

n x m matrix

If max [i,j]=k,

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

  1. Allocation

n x m matrix

If allocation [i,j]=k,

than Pi is currently allocated k instances of resource Rj.

  1. 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]

 

Leave a Reply

Your email address will not be published. Required fields are marked *

111 Views
%d bloggers like this: