The Gateway to Computer Science Excellence
+24 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
in Operating System by Boss (16.3k points)
edited by | 2.3k views

I think in question it should be R instead of Rh


first given R1 and R2 to P1 and complete it then given to again R1,R2 to P2 ..

ans should be 1 and 2  or 3 and 4   can ensure no deadlock

3 Answers

+11 votes
Best answer

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

by Active (3.6k points)
edited by
+27 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 .

by (91 points)
edited by
Yes. Both I and II as well as III and IV can ensure no deadlock.
@Arjun Sir : If u can please elaborately explain ,can't understand the above solution
1.  T11 > T21 :  Allocate R1 to process P1.

2.  T12 > T22 : Allocate R2 to process P1.


3.  T11 < T21 :  Allocate R1 to process P2.

4.  T12 < T22 : Allocate R2 to process P2.

Allocation of all resources to one process never cause deadlock. Once that process complete execution resources will be free and are available to allocate some other process. Deadlock never happen..

That will be given by 1 & 2 As well as 3 & 4..
Thanks :)
Thqq soo much...
+6 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.
by Loyal (10k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,650 questions
56,242 answers
95,935 users