in Operating System edited by
10,892 views
25 votes
25 votes

A single processor system has three resource types $X, Y$ and $Z$, which are shared by three processes. There are $5$ units of each resource type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process, and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of these processes will finish LAST?

$$\begin{array}{|l|lll|ll|}\hline &\text{}  \rlap{\textbf{alloc}}  &&&\rlap{  \textbf{request}}  \\\hline  &\text{X} & \text{Y} & \text{Z}  &\text{X} & \text{Y} & \text{Z}  \\\hline  \textbf{P0} & \text{1} & \text{2} & \text{1}& \text{1} & \text{0} & \text{3}  \\\hline  \textbf{P1} & \text{2} & \text{0} & \text{1} & \text{0} & \text{1} & \text{2} \\\hline \textbf{P2} & \text{2} & \text{2} & \text{1} & \text{1} & \text{2} & \text{0} \\\hline \end{array}$$

  1. $P0$
  2. $P1$
  3. $P2$
  4. None of the above, since the system is in a deadlock
in Operating System edited by
10.9k views

1 comment

Banker's Algorithm

0
0

2 Answers

30 votes
30 votes
Best answer

The answer is (C).

$$\overset{\text{Available Resources}}{\begin{array}{|l|l|l||}\hline
\text{X} & \text{Y} & \text{Z} \\\hline  \text{0} & \text{1} & \text{2}
\\\hline\end{array}}$$ Now, $P1$ will execute first, As it meets the needs. After completion, The available resources are updated.

$$\qquad  \overset{\text{Updated Available Resources}}{\begin{array}{|l|l|l||}\hline
\text{X} & \text{Y} & \text{Z} \\\hline  \text{2} & \text{1} & \text{3}
\\\hline\end{array}}$$
Now $P0$ will complete the execution, as it meets the needs.

After completion of $P0$ the table is updated and then $P2$ completes the execution.

Thus $P2$ completes the execution in the last.

edited by

4 Comments

In this particular question, only one safe sequence is possible.

$P_{1}\rightarrow P_{0}\rightarrow P_{2}$

0
0

Why P0 not executed first like available resources is 0,1,2 and allocated to P0 is 1,2,1 . If we allocate 0,1,2 to P0 then it get 1,3,3 which satisfy the request made by P0 which is 1,0,3 .

0
0
Request is not maximum need, It's current need. If it would have been maximum need then Y alloc to P0 never had been 2.
0
0
0 votes
0 votes
Here there are two safe sequence possible

P1--> P0 -->P2 and P1-->P2-->P0 hence both option A and C are correct
Answer:

Related questions