Bankers Algorithm:

• Banker’s Algorithm is a deadlock avoidance strategy.
• It is called so because it is used in banking systems to decide whether a loan can be granted or not.

 Banker’s Algorithm requires-
               Whenever a new process is created, it specifies the maximum number of instances of each resource type that it exactly needs.


DataStructures used in bankers alogorithm

Available:

• It is a 1-d array of size ‘m’ indicating the number of available resources of each type. 

• Available[j] = k means there are ‘k’ instances of resource type Rj 

Max: 

• It is a 2-d array of size ‘n*m’ that defines the maximum demand of each process in a system.

• Max[i,j] = k means process Pi may request at most ‘k’ instances of resource type Rj.

Allocation

• It is a 2-d array of size ‘n*m’ that defines the number of resources of each type currently allocated to each process. 

• Allocation [i, j] = k means process Pi is currently allocated ‘k’ instances of resource type Rj.

 Need: 

• It is a 2-d array of size ‘n*m’ that indicates the remaining resource need of each process. 

• Need [i, j] = k means process Pi currently need ‘k’ instances of resource type Rj for its execution. 

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


Problems on Bankers algorithm:

1Q.A single processor system has three resource types X, Y and Z, which are shared by three processes. There are 5 units of each resource type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process, and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of these processes will finish LAST?

  1. P0
  2. P1
  3. P2
  4. None of the above since the system is in a deadlock







Popular Post

MindMaps

Featured post

Question 1: Reverse Words in a String III

  def reverseWords(s: str) -> str: words = s.split() return ' '.join(word[::-1] for word in words)