GateAI
Deadlock

GATE CSE 2017 Set 1 · Q27

MCQ2 marksMedium

Time

A multithreaded program PP executes with xx number of threads and uses yy number of locks for ensuring mutual exclusion while operating on shared memory locations. All locks in the program are *non-reentrant*, i.e., if a thread holds a lock ll, then it cannot re-acquire lock ll without releasing it. If a thread is unable to acquire a lock, it blocks until the lock becomes available. The *minimum* value of xx and the *minimum* value of yy together for which execution of PP can result in a deadlock are:

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: D) x = 1, y = 1

Deadlock

A non-reentrant (or non-recursive) lock cannot be acquired again by the thread currently holding it without releasing it first.

Consider a single thread (x=1x = 1) and a single lock (y=1y = 1):

  1. Thread T1T_1 acquires lock L1L_1.

  2. While still holding L1L_1, thread T1T_1 attempts to acquire L1L_1 again.

  3. Since the lock is non-reentrant and currently held, T1T_1 blocks waiting for L1L_1 to be released.

  4. Since T1T_1 is blocked, it can never execute the statement to release L1L_1.

This creates a self-deadlock scenario. Therefore, the minimum number of threads and locks that can result in deadlock are x=1x = 1 and y=1y = 1.

Hence, the correct option is (D).

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 Q27 of the GATE CSE 2017 Set 1 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. 4 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2017 Set 1.

How GATE tests Deadlock

More from GATE CSE 2017 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2017 Set 1 · Q27 · MCQ

A multithreaded program P executes with x number of threads and uses y number of locks for ensuring mutual exclusion while operating on shared memory locations. All locks in the program are *non-reentrant*, i.e., if a thread holds a lock l, then it cannot re-acquire lock l without releasing it. If a thread is unable to acquire a lock, it blocks until the lock becomes available. The *minimum* value of x and the *minimum* value of y together for which execution of P can result in a deadlock are:

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.