GateAI
Concurrency and Synchronization

GATE CSE 2015 Set 3 · Q10

MCQ1 markMedium

Time

Two processes XX and YY need to access a critical section. Consider the following synchronization construct used by both the processes Here, varP and varQ are shared variables and both are initialized to false. Which one of the following statements is true?

GATE CSE 2015 Set 3 Q10 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) The proposed solution prevents deadlock but fails to guarantee mutual exclusion

Concurrency and Synchronization

Let us analyze the synchronization code:

  1. Mutual Exclusion:

    • Initially, varP = false and varQ = false.

    • Suppose Process XX sets varP = true. Before evaluating its while condition, a context switch occurs to Process YY.

    • Process YY sets varQ = true.

    • Now, Process XX checks while(varQ == true), which evaluates to true, so XX enters the while loop body and thus the Critical Section.

    • Simultaneously, Process YY checks while(varP == true), which also evaluates to true, so YY enters the while loop body and thus the Critical Section at the same time.

    • Therefore, mutual exclusion is not guaranteed.

  2. Deadlock:

    • Neither process can be blocked in an infinite busy-wait loop because there are no loops without exit conditions or blocking waits; the loop is entered only if the condition is true and immediately resets the flag inside, or skipped if false.

    • Hence, deadlock is prevented.

Thus, the proposed solution prevents deadlock but fails to guarantee mutual exclusion, which matches (A).

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 Q10 of the GATE CSE 2015 Set 3 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 it is the only one in GATE CSE 2015 Set 3.

How GATE tests Concurrency and Synchronization

More from GATE CSE 2015 Set 3

Share this solution

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

GateAI solution cardGATE CSE 2015 Set 3 · Q10 · MCQ

Two processes X and Y need to access a critical section. Consider the following synchronization construct used by both the processes Here, varP and varQ are shared variables and both are initialized to false. Which one of the following statements is true?

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.