Numerical Solved by Deadlock Detection Algorithm

Q2. Apply deadlock detection algorithm to the following an show the result

Available = [ 2 1 0 0]

Allocation = [0 0 1 0]

                      [2 0 0 1]

                      [0 1 2 0]

Request = [2 0 0 1]

                   [1 0 1 0]

                   [2 1 0 0]

Solu:

Process Allocation Request Available
P0
P1
P2
A B C D
0 0 1 0
2 0 0 1
0 1 2 0
A B C D
2 0 0 1
1 0 1 0
2 1 0 0
A B C D
2 1 0 0

Step 1:

For process P0

request0 ≤ available

(2, 0, 0, 1) ≤ (2, 1, 0, 0)

Process P0 must wait.

Step 2:

For process P1

request1 ≤ available

(1, 0, 1, 0) ≤ (2, 1, 0, 0)

Process P1 must wait.

Step 3:

For process P2

request2 ≤ available

(2, 1, 0, 0) ≤ (2, 1, 0, 0)

Process P2 will execute.

Available = Available + Allocation

Available = (2, 1, 0, 0) + (0, 1, 2, 0)

= (2, 2, 2, 0)

Step 4:

For process P0

request0 ≤ available

(2, 0, 0, 1) ≤ (2, 2, 2, 0)

P0 must wait.

Step 5:

For process P1

request1 ≤ available

(1, 0, 1, 0) ≤ (2, 2, 2, 0)

P1 will execute.

                Available = Available + Allocation

= (2, 2, 2, 0) + (2, 0, 0, 1)

= (4, 2, 2, 1)

Step 6:

For process P0

request0 ≤ available

(2, 0, 0, 1) ≤(4, 2, 2, 1)

P0 will execute.

Available = Available + Allocation

= (4, 2, 2, 1) + (0, 0, 1, 0)

= (4, 2, 3, 1)

Safety sequence = < P2, P1, P0>

Leave a Reply

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

270 Views
%d bloggers like this: