Numerical Solved with Deadlock Detection Algorithm

Q3. Use deadlock algorithm, there are five processes and 3 resource type

A -> 7 instances

B -> 2 instances

C -> 6 instances

Process Allocation Request Available
P0
P1
P2
P3
P4
A B C
0 1 0
2 0 0
3 0 3
2 1 1
0 0 2
A B C
0 0 0
2 0 2
0 0 0
1 0 0
0 0 2
A B C
0 0 0
     
     
     
     

Solu:

Step 1:

For process P0

request0 available

(0, 0, 0) ≤ (0, 0, 0)

Process P0 will execute.

Available = Available + Allocation

request1 ≤ available

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

P1 must wait.

Step 3:

For process P2

                request2 ≤ available

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

P2 will execute.

Available = Available + Allocation

= (0, 1, 0) + (3, 0, 3)

= (3, 1, 3)

Step 4:

For process P3

request3 ≤ available

(1, 0, 0) ≤ (3, 1, 3)

P3 will execute.

Available = Available + Allocation

= (3, 1, 3) + (2, 1, 1)

= (5, 2, 4)

Step 5:

For process P4

request4 ≤ available

(0, 0, 2) ≤ (5, 2, 4)

P4 will execute.

Available = Available + Allocation

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

= (5, 2, 6)

Step 6:

For process P1

request1 ≤ available

(2, 0, 1) ≤ (5, 2, 6)

P1 will execute.

Available = Available + Allocation

= (5, 2, 6) + (2, 0, 0)

= (7, 2, 6)

Safety sequence = <P0, P2, P3, P4, P1>

Leave a Reply

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

577 Views
%d bloggers like this: