0
9.7kviews
Consider the following system snapshot using data structures in the Banker's algorithm
Process Max Allocation Available
A,B,C,D A,B,C,D A,B,C,D
P0 6 0 1 2 4 0 0 1 3 2 1 1
P1 1 7 5 0 1 1 0 0
P2 2 3 5 6 1 2 5 4
P3 1 6 5 3 0 6 3 3

Using Banker's algorithm answer the following questions :-

(i) How many resources to type A,B,C and D are there?

(ii) What are the contents of Need Matrix?

(iii) Is the system is in safe state? find the state sequence if it is.

1 Answer
1
1.1kviews

[i] How many resources to type A, B, C, and D are there?

The Total Amount of Resources = Sum of Columns of Allocation + Available Resource

= [6 9 8 8] + [3 2 1 1] = [9 11 9 9]

[II] What are the contents of the Need Matrix?

Calculation of the Need Matrix

Need [i] = Max [i] - Allocation [I]

Need for P0: (6, 0, 1, 2) – (4, 0, 0, 1) = (2, 0, 1, 1)

Need for P1: (1, 7, 5, 0) – (1, 1, 0, 0) = (0, 6, 5, 0)

Need for P2: (2, 3, 5, 6) – (1, 2, 5, 4) = (1, 1, 0, 2)

Need for P3: (1, 6, 5, 3) – (0, 6, 3, 3) = (1, 0, 2, 0)

Need Matrix looks like in the following manner:

b1

[iii] Is the system is in a safe state? find the state sequence if it is.

Available Resources are Available = (3, 2, 1, 1)

Now check if each type of resource request is available for each process or not

Step 1: For Process P0:

Need <= Available

2, 0, 1, 1 <= 3, 2, 1, 1 condition is True.

New available = available + Allocation

(3, 2, 1, 1) + (4, 0, 0, 1) = > 7, 2, 1, 2

Step 2: For Process P1:

Need <= Available

0, 6, 5, 0 <= 7, 2, 1, 2 condition is False.

Step 3: For Process P2:

Need <= Available

1, 1, 0, 2 <= 7, 2, 1, 2 condition is True.

New available = available + Allocation

(7, 2, 1, 2) + (1, 2, 5, 4) => 8, 4, 6, 6

Step 4: For Process P3:

Need <= Available

1, 0, 2, 0 <= 8, 4, 6, 6 condition is True.

New available = available + Allocation

(8, 4, 6, 6) + (0, 6, 3, 3) => 8, 10, 9, 9

Step 5: Now again check for Process P1:

Need <= Available

0, 6, 5, 0 <= 8, 10, 9, 9 condition is True.

New available = available + Allocation

(8, 10, 9, 9) + (1, 1, 0, 0) => 9, 11, 9, 9

Hence, execute the banker's algorithm to find the safe state and the safe sequence like P0, P2, P3, and P1 for available resources (3, 2, 1, 1)

Order of Safe Sequence = P0, P2, P3, P1

The system allocates all the needed resources to each process. So, we can say that the system is in a safe state.

Please log in to add an answer.