Friday, 23 October 2020

PRACTICE PROBLEMS BASED ON BANKER’S ALGORITHM

 

Problem-01:


Considering a system with four processes P0 through P3 and three resources of type A, B, C. Resource type A has 10 instances, B has 5 instances and type C has 7 instances. Suppose at time t0 following snapshot of the system has been taken:





Question1. What will be the content of the Need matrix?

Question2.  Is the system in a safe state? If Yes, then what is the safe sequence?

Problem-02:


Question1. What will be the content of the Need matrix?

Question2.  Is the system in a safe state? If Yes, then what is the safe sequence?

Question3. What will happen if process Prequests one additional instance of resource type A and two instances of resource type C?


Problem-03:

 

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



Problem-04:

 

An operating system uses the banker’s algorithm for deadlock avoidance when managing the allocation of three resource types X, Y and Z to three processes P0, P1 and P2. The table given below presents the current system state. Here, the Allocation matrix shows the current number of resources of each type allocated to each process and the Max matrix shows the maximum number of resources of each type required by each process during its execution.

AllocationMax
XYZXYZ
P0001843
P1320620
P2211333

 

There are 3 units of type X, 2 units of type Y and 2 units of type Z still available. The system is currently in safe state. Consider the following independent requests for additional resources in the current state-

 

REQ1: P0 requests 0 units of X, 0 units of Y and 2 units of Z

REQ2: P1 requests 2 units of X, 0 units of Y and 0 units of Z

 

Which of the following is TRUE?

  1. Only REQ1 can be permitted
  2. Only REQ2 can be permitted
  3. Both REQ1 and REQ2 can be permitted
  4. Neither REQ1 nor REQ2 can be permitted


Problem-05:

 

A system has 4 processes and 5 allocatable resource. The current allocation and maximum needs are as follows-

AllocatedMaximum
A1021111213
B2011022210
C1101121311
D1111011220

 

If Available = [ 0 0 X 1 1 ], what is the smallest value of x for which this is a safe state?


Problem-06:

An operating system uses the Banker’s algorithm for deadlock avoidance when managing the allocation of three resource types X, Y, and Z to three processes P0, P1, and P2. The table given below presents the current system state. Here, the Allocation matrix shows the current number of resources of each type allocated to each process and the Max matrix shows the maximum number of resources of each type required by each process during its execution.

GATECS2014Q42

There are 3 units of type X, 2 units of type Y and 2 units of type Z still available. The system is
currently in a safe state. Consider the following independent requests for additional resources in the
current state:

REQ1: P0 requests 0 units of X,  
      0 units of Y and 2 units of Z
REQ2: P1 requests 2 units of X, 
      0 units of Y and 0 units of Z

Which one of the following is TRUE?
(A) Only REQ1 can be permitted.
(B) Only REQ2 can be permitted.
(C) Both REQ1 and REQ2 can be permitted.
(D) Neither REQ1 nor REQ2 can be permitted


Problem-07:


 A system has 12 magnetic tape drives and 3 processes : P0, P1, and P2. Process P0 requires 10 tape drives, P1 requires 4 and P2 requires 9 tape drives.

Process    
P0            
P1                             
P2                             
 
Maximum needs (process-wise: P0 through P2 top to bottom)    
10             
4   
9
 
Currently allocated (process-wise)
5
2
2

Which of the following sequence is a safe sequence?
a) P0, P1, P2
b) P1, P2, P0
c) P2, P0, P1
d) P1, P0, P2

No comments:

Post a Comment