442 views

A number of processes could be in a deadlock state if none of them they execute due to non-availability of sufficient resources. Let $P_i, 0 \leq i \leq 4$ represent five processes and let there be four resources types $r_j, 0 \leq j \leq 3$. Suppose the following data structures have been used.

Available: A vector of length 4 such that if Available $[i]=k$, there are k instances of resource type $r_j$ available in the system.

Allocation. A 5 $\times$ 4 matrix defining the number of each type currently allocated to each process. If Allocation $[i,j]=k$ then process $p_i$ is currently allocated $k$ instances of resource type $r_j$.

Max. A 5 $\times$ 4 matrix indicating the maximum resource need of each process. If $Max[i,j]=k$ then process $p_i$, may need a maximum of $k$ instances of resource type $r_j$ in order to complete the task.

Assume that system allocated resources only when it does not lead into an unsafe state such that resource requirements in future night cause a deadlock state. Now consider the following snapshot of the system.

 $$\textbf{Allocation}$$ r0 r1 r2 r3 $p_0$ 0 0 1 2 $p_1$ 1 0 0 0 $p_2$ 1 3 5 4 $p_3$ 0 6 3 2 $p_4$ 0 0 1 4
 $$\textbf{Max}$$ r0 r1 r2 r3 0 0 1 2 1 7 5 0 2 3 5 6 0 6 5 2 0 6 5 6
 $$\textbf{Available}$$ r0 r1 r2 r3 1 5 2 0

Is the system currently in a safe state? If yes, explain why.

+1

Let me know if i m wrong...

+1 vote
Need Matrix:-

0   0   0   0

0   7   5   0

1   0   0   2

0   0   2   0

0   6   4   2

P0---->available 1   5   3   2

P2---->available 2   8   8   6

P1---->P3---->P4
Yes System is in Safe state .

Safe sequence is P0,P2,P1,P3,P4
yes it is safe state and safe sequence is P0->P2->P1->P3->P4->