Consider the following Deadlock Avoidance problem Consider t

Consider the following Deadlock Avoidance problem.

Consider the following Deadlock Avoidance problem. Suppose there are 4 processes in the system and 4 types of resources. Suppose the maximum resources claimed by these 4 processes are: Suppose at time t, the allocation matrix and the available vector are: Is the current state a safe state? Suppose now process P1 asks for (1, 1, 1, 1). Will the system grant the request?

Solution

Allocation

R1 R2 R3 R4

Max

R1 R2 R3 R4

Need(Max-Allocation)

R1 R2 R3 R4

Available

R1 R2 R3 R4

2 2 2 2

P1 cannot execute because Available < Need ([3 2 1 1] < [2 2 2 2]),work = [2 2 2 2]

P2 can execute , as Available > Need ([2 2 2 2] > [1 0 2 1]) , work = work+ Allocation = [2 2 2 2] +[3 0 1 0] = [5 2 3 2]

P1 can execute now, as Available > Need ([5 2 3 2 ] > [3 2 1 1]) , work = work+ Allocation = [5 2 3 2 ] +[2 1 3 1]

= [ 7 3 6 3 ]

P3 can execute now, as Available > Need ([7 3 6 3] > [3 2 1 2]) , work = work+ Allocation = [7 3 6 3 ] +[2 2 1 1]

= [ 9 5 7 4 ]

P4 can execute now, as Available > Need ([9 5 7 4] > [2 0 1 1]) , work = work+ Allocation = [9 5 7 4 ] +[1 2 1 3]

= [ 10 7 8 7 ]

So <P2,P1,P3,P4> is the safe sequence of process execution. Hence current state is a safe state.

Yes, if P1 asks for(1,1,1,1) the system will grant it as Need < Available.

Process

Allocation

R1 R2 R3 R4

Max

R1 R2 R3 R4

Need(Max-Allocation)

R1 R2 R3 R4

Available

R1 R2 R3 R4

2 2 2 2

P1 2 1 3 1 5 3 4 2 3 2 1 1
P2 3 0 1 0 4 0 3 1 1 0 2 1
P3 2 2 1 1 5 4 2 3 3 2 1 2
P4 1 2 1 3 3 2 2 4 2 0 1 1
Consider the following Deadlock Avoidance problem. Consider the following Deadlock Avoidance problem. Suppose there are 4 processes in the system and 4 types of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site