GateAI
Concurrency and Synchronization

GATE CSE 2013 · Q16

MCQ1 markMedium

Time

Three concurrent processes XX, YY, and ZZ execute three different code segments that access and update certain shared variables. Process XX executes the PP operation (i.e., wait) on semaphores aa, bb and cc; process YY executes the PP operation on semaphores bb, cc and dd; process ZZ executes the PP operation on semaphores cc, dd, and aa before entering the respective code segments. After completing the execution of its code segment, each process invokes the VV operation (i.e., signal) on its three semaphores. All semaphores are binary semaphores initialized to one. Which one of the following represents a deadlock-free order of invoking the PP operations by the processes?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) X: P(b)P(a)P(c) Y: P(b)P(c)P(d) Z: P(a)P(c)P(d)

Concurrency and Synchronization

To prevent deadlock among concurrent processes requesting multiple shared resources, a standard technique is resource ordering (Dijkstra's resource hierarchy). If all processes request resources in accordance with a strict total order, a circular wait condition is impossible.

Let us check the ordering in Option B:

  • Process XX: P(b)→P(a)→P(c)P(b) \to P(a) \to P(c)

  • Process YY: P(b)→P(c)→P(d)P(b) \to P(c) \to P(d)

  • Process ZZ: P(a)→P(c)→P(d)P(a) \to P(c) \to P(d)

Define the total ordering of semaphores as:

b<a<c<db < a < c < d

Let us verify each process against this total ordering:

  • Process XX requests b,a,cb, a, c, which follows b<a<cb < a < c.

  • Process YY requests b,c,db, c, d, which follows b<c<db < c < d.

  • Process ZZ requests a,c,da, c, d, which follows a<c<da < c < d.

Since all processes request resources in strictly monotonically increasing order according to b<a<c<db < a < c < d, circular wait cannot occur, and hence execution is guaranteed to be deadlock-free.

In all other options, there is a cycle in the request graph, which can lead to a deadlock under interleaved execution.

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 Concurrency and Synchronization previous year question is Q16 of the GATE CSE 2013 paper. Find more GATE CSE PYQs on Concurrency and Synchronization 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 Concurrency and Synchronization 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.

Concurrency and Synchronization in GATE CSE

Concurrency and Synchronization has 18 GATE CSE PYQs across 15 papers from 2012 to 2026. 3 of them are 1-mark MCQs like this one, and GATE CSE 2013 has 3.

How GATE tests Concurrency and Synchronization

More from GATE CSE 2013

Share this solution

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

GateAI solution cardGATE CSE 2013 · Q16 · MCQ

Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P operation on semaphores c, d, and a before entering the respective code segments. After completing the execution of its code segment, each process invokes the V operation (i.e., signal) on its three semaphores. All semaphores are binary semaphores initialized to one. Which one of the following represents a deadlock-free order of invoking the P operations by the processes?

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.