GateAI
Deadlock

GATE CSE 2021 Set 2 · Q43

MSQ2 marksMedium

Time

Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock (L). The following scheme is used to own a resource instance :function OWNRESOURCE(Resource R) Acquire lock L // a global lock if R is available then Acquire R Release lock L else if R is owned by another process P then Terminate P, after releasing all resources owned by P Acquire R Restart P Release lock L end if end if end functionWhich of the following choice(s) about the above scheme is/are correct?

Select all that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official answer: A) The scheme ensures that deadlocks will not occur.; B) The scheme may lead to live-lock.; C) The scheme may lead to starvation.

Deadlock

Let us analyze the given resource allocation scheme against each statement:

  1. Deadlock Freedom (Option A):

    • Deadlock requires four necessary conditions: Mutual Exclusion, Hold and Wait, No Preemption, and Circular Wait.

    • In this scheme, if a requested resource RR is currently held by process PP, PP is immediately terminated and all its held resources are forcibly released (preempted). Because preemption is enforced, circular wait cannot persist, ensuring that deadlocks will not occur. Hence, (A) is correct.

  2. Livelock (Option B):

    • Consider two processes, P1P_1 and P2P_2, competing for resources R1R_1 and R2R_2. Suppose P1P_1 holds R1R_1 and requests R2R_2 (held by P2P_2), causing P2P_2 to be terminated and restarted. Then restarted P2P_2 requests R1R_1, terminating and restarting P1P_1. This cycle of mutual preemption and restarting can repeat indefinitely with processes actively executing without making any forward progress, which is a classic live-lock condition. Hence, (B) is correct.

  3. Starvation (Option C):

    • Since a process holding a resource can be repeatedly preempted, terminated, and restarted whenever another process requests its resource, an unlucky process may never finish execution, leading to starvation. Hence, (C) is correct.

  4. Mutual Exclusion (Option D):

    • The global lock LL ensures atomic check-and-acquisition. If a resource is not available, the current owner is terminated and all its resources are released before the requesting process acquires it. At any moment, at most one process owns an instance of a resource. Thus, mutual exclusion is strictly preserved and not violated. Hence, (D) is incorrect.

Therefore, the correct options are A, B, and C.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Deadlock previous year question is Q43 of the GATE CSE 2021 Set 2 paper. Find more GATE CSE PYQs on Deadlock in Operating Systems, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Deadlock PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Deadlock in GATE CSE

Deadlock has 11 GATE CSE PYQs across 10 papers from 2014 to 2026. 2 of them are 2-mark MSQs like this one, and it is the only one in GATE CSE 2021 Set 2.

How GATE tests Deadlock

More from GATE CSE 2021 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2021 Set 2 · Q43 · MSQ

Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock (L). The following scheme is used to own a resource instance : function OWNRESOURCE(Resource R) Acquire lock L // a global lock if R is available then Acquire R Release lock L else if R is owned by another process P then Terminate P, after releasing all resources owned by P Acquire R Restart P Release lock L end if end if end function Which of the following choice(s) about the above scheme is/are correct?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.