Consider the following system snapshot using data structures in the Banker’s algorithm, with resources A, B, C, and D, and process P0 to P4:




Using Banker’s algorithm, answer the following questions.
  1. How many resources of type A, B, C, and D are there? 
  2. What are the contents of the Need matrix? 
  3. Is the system in a safe state? Why  
  4. If a request from process P4 arrives for additional resources of (1,2,0,0,), can the Banker’s algorithm grant the request immediately? Show the new system state and other criteria.
Ans:
(a)
A-9; B-13;C-10;D-11
(b) Need[i, j]=Max[i,j]-Allocation[i,j] so content of Need matrix is ABCD
  1. P0  2 0 1 1
  2. P1  0 6 5 0
  3. P2  1 1 0 2
  4. P3  1 0 2 0
  5. P4  1 4 4 4
(c) The system is in a safe state as the processes can be finished in the sequence P0, P2, P4, P1 and P3.
(d) If a request from process P4 arrives for additional resources of (1,2,0,0,), and if this request is granted, the new system state would be tabulated as
follows.
 

0 comments:

Feel free to contact the admin for any suggestions and help.