The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+23 votes
2.1k views

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
asked in Operating System by Boss (16.3k points)
edited by | 2.1k views
+3

I think in question it should be R instead of Rh

3 Answers

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

answered by Active (3.4k points)
edited by
+26 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 .

answered by (91 points)
edited by
+29
Yes. Both I and II as well as III and IV can ensure no deadlock.
0
@Arjun Sir : If u can please elaborately explain ,can't understand the above solution
+30
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..
0
Thanks :)
0
Thqq soo much...
+5 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.
answered by Loyal (9.7k points)
Answer:

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
49,814 questions
54,518 answers
188,351 comments
75,294 users