• edited by
15,250 views
55 55 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

7 Answers

Best answer
58 58 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
33 33 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 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.
0 0 votes
Option C is right

suppose P2 get the resource R1 and P1 try to get that resource but due to low priority it will get stuck also if P2 get the resource R2 and P1 try to snatch it but due to low priority again it get stuck and in both the cases deadlock will occur.

if the resource allocate to P1 and P2 try to snatch it, it will do it because of higher priority and deadlock would be avoided.
Answer:
Position:
Show:

Related questions

99 99 votes
7 answers 7 answers
25.4k
25.4k views
Ishrat Jahan asked Nov 3, 2014
25,435 views
A disk has $8$ equidistant tracks. The diameters of the innermost and outermost tracks are $1$ cm and $8$ cm respectively. The innermost track has a storage capacity of $...
54 54 votes
4 answers 4 answers
17.6k
17.6k views
Ishrat Jahan asked Nov 3, 2014
17,588 views
A disk has $8$ equidistant tracks. The diameters of the innermost and outermost tracks are $1$ cm and $8$ cm respectively. The innermost track has a storage capacity of $...
49 49 votes
3 answers 3 answers
11.1k
11.1k views
Ishrat Jahan asked Nov 3, 2014
11,080 views
In a computer system, four files of size $11050$ bytes, $4990$ bytes, $5170$ bytes and $12640$ bytes need to be stored. For storing these files on disk, we can use either...
31 31 votes
3 answers 3 answers
9.2k
9.2k views
Ishrat Jahan asked Nov 3, 2014
9,164 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...