Two shared resources R1 and R2 are used by processes P1 and P2. Each process…

2005

Two shared resources R1 and R2 are used by processes P1 and P2. Each process has a certain priority for accessing each resource. Let Tij denote the priority of Pi for accessing  Rj. A process Pi can snatch a resource Rh from process Pj if Tik is greater than Tjk. Given the following :

  1. T11 > T21

  2. T12 > T22

  3. T11 < T21

  4. T12 < T22

Which of the following conditions ensures that P1 and P2can never deadlock?  

  1. A.

    (I) and (IV)

  2. B.

    (II) and (III)

  3. C.

    (I) and (II)

  4. D.

    None of the above

Attempted by 129 students.

Show answer & explanation

Correct answer: C

Correct condition: T11 > T21 and T12 > T22. This means the first process has higher priority on both resources.

Reasoning:

  • A process can snatch a resource from the other only if it has higher priority for that resource.

  • If the first process has higher priority on both resources, then whenever the second process holds a resource the first process can snatch it. Therefore the second process cannot indefinitely hold a resource needed by the first, preventing a circular wait.

  • Thus the condition that the first process has higher priority on both resources ensures deadlock cannot occur.

Why the other combinations fail:

  • When each process has higher priority on a different resource (for example, the first process higher on the first resource while the second process is higher on the second resource), each can hold one resource that the other wants and neither can snatch the other's resource, allowing a circular wait and possible deadlock.

  • Consequently, only the scenario where one process strictly dominates the other on all resources (first process higher on both or second process higher on both) prevents deadlock. Among the given choices, the listed condition where the first process has higher priority on both resources is the correct deadlock-preventing condition.

Explore the full course: Gate Guidance By Sanchit Sir