edited by
8,691 views
37 votes
37 votes

Two shared resources $R_1$ and $R_2$ are used by processes $P_1$ and $P_2$. Each process has a certain priority for accessing each resource. Let $T_{ij}$ denote the priority of $P_i$ for accessing  $R_j$. A process $P_i$ can snatch a resource $R_k$ from process $P_j$ if $T_{ik}$ is greater than $T_{jk}$.
Given the following :

  1. $T_{11} > T_{21}$
  2. $T_{12} > T_{22}$
  3. $T_{11} < T_{21}$
  4. $T_{12} < T_{22}$

Which of the following conditions ensures that $P_1$ and $P_2$ can never deadlock?

  1. (I) and (IV)
  2. (II) and (III)
  3. (I) and (II)
  4. None of the above
edited by

3 Answers

Best answer
41 votes
41 votes

If any process has highest priority over all the resources then it can snatch any resource from any other process and so no deadlock can occur with another process as this highest priority process will eventually finish and release all the resources for the other less priority process.

In case of (I) and (II) process $1$ has given highest priority over all the resources and hence deadlock cannot occur.

Similarly, in the case of (III) and (IV) process $2$ has given highest priority over all the resources and hence deadlock cannot occur.

If we consider option (A) (I) and (IV)

  •  $T_{11} > T_{21}$     // for resource 1, process 1 has the highest priority
  •  $T_{22} > T_{12}$     // for resource 2 , process 2 has highest priority

Let $P_1$ be holding $R_1$ and waiting for $R_2.$

Let $P_2$ be holding $R_2$ and waiting for $R_1.$

This is deadlock as neither is releasing its held resources.

Similarly in option B also deadlock can occur.

Correct answer : C

edited by
30 votes
30 votes

The answer is (C)

If $R_1$ and $R_2$ are allocated to the Process $P_1$ , then it will complete it's job and release it . After that process $P_2$  will get both the resources and complete it's Job .

edited by
7 votes
7 votes
Now according to first option::C

T11>T21 Here Process P1 first take resourses and excute

T12>T22 ,Here again process P1 takes resourses and execute in short both of the resourses is taken by process first alone and it complete its execution and after completing it free all its resourses .So it is surely from from all types of deadlock.
Answer:

Related questions

27 votes
27 votes
1 answer
4
Ishrat Jahan asked Nov 3, 2014
5,372 views
We wish to schedule three processes $P1$, $P2$ and $P3$ on a uniprocessor system. The priorities, CPU time requirements and arrival times of the processes are as shown be...