edited by
10,998 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
edited by

2 Answers

Best answer
30 votes
30 votes

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
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

16 votes
16 votes
4 answers
1
go_editor asked Apr 23, 2016
6,628 views
A process, has been allocated $3$ page frames. Assume that none of the pages of the process are available in the memory initially. The process makes the following sequenc...