GateAI
Concurrency and Synchronization

GATE CSE 2016 Set 1 · Q50

MCQ2 marksHard

Time

Consider the following proposed solution for the critical section problem. There are nn processes: P0…Pn−1P_0 \dots P_{n-1}. In the code, function pmax returns an integer not smaller than any of its arguments. For all ii, t[i] is initialized to zero. Code for PiP_i:do { c[i]=1; t[i] = pmax(t[0],...,t[n-1])+1; c[i]=0; for every j ≠ i in {0,...,n-1} { while (c[j]); while (t[j] != 0 && t[j]<=t[i]); } Critical Section; t[i]=0; Remainder Section; } while (true);Which one of the following is TRUE about the above solution?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) At most one process can be in the critical section at any time

Concurrency and Synchronization

Let us analyze the given synchronization algorithm (a variant of Lamport's Bakery Algorithm):

  1. Mutual Exclusion / At most one process in Critical Section:

    • To enter the Critical Section, process PiP_i checks for every j≠ij \neq i whether t[j]≠0t[j] \neq 0 and t[j]≤t[i]t[j] \le t[i].

    • If all active processes have distinct ticket values tt, the process with the strictly smallest ticket will pass the while loop and enter the Critical Section, while all other processes wait. Hence, two processes with different ticket numbers cannot enter simultaneously.

    • If two processes PiP_i and PjP_j happen to receive the same ticket value (t[i]=t[j]t[i] = t[j]), both will wait on each other indefinitely because the condition t[j] <= t[i] evaluates to true for both PiP_i (checking PjP_j) and PjP_j (checking PiP_i). This causes a deadlock, meaning neither enters the critical section.

    • Thus, under no circumstances can more than one process be in the critical section at the same time. Hence, at most one process can be in the critical section at any time.

  2. Deadlock / Progress:

    • In standard Bakery algorithms, ties in ticket numbers are broken using process IDs (e.g., (t[i],i)<(t[j],j)(t[i], i) < (t[j], j)). Here, there is no tie-breaking rule; the condition is simply t[j] <= t[i].

    • If t[i]=t[j]t[i] = t[j], both processes wait for each other, resulting in a deadlock. Therefore, it *can* cause deadlock, and the progress and bounded waiting conditions fail.

Thus, statement (A) is TRUE.

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

How GATE tests Concurrency and Synchronization

More from GATE CSE 2016 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2016 Set 1 · Q50 · MCQ

Consider the following proposed solution for the critical section problem. There are n processes: P0 Pn-1. In the code, function pmax returns an integer not smaller than any of its arguments. For all i, t[i] is initialized to zero. Code for Pi: do { c[i]=1; t[i] = pmax(t[0],...,t[n-1])+1; c[i]=0; for every j ≠ i in {0,...,n-1} { while (c[j]); while (t[j] != 0 && t[j] Which one of the following is TRUE about the above solution?

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.