GATE CS 2026 (Afternoon) — Question 51

Operating Systems (OS)Concurrency & Synchronization (Semaphores, Mutex, Monitors, Locks)MSQ2 marksHard

Consider three processes P1, P2, and P3 running identical code, as shown in the pseudocode below. A and B are two binary semaphores initialized to 1 and 0, respectively. X is a shared variable initialized to 0. Each line in the pseudocode is executed atomically. Pseudocode of P1, P2, and P3
code
1Wait(A);
2Print(*);
3X = X+1;
4If (X == 2)
5{
6    Print($);
7    Signal(B);
8}
9Signal(A);
10Wait(B);
11Print(#);
12Signal(B);
13
Assume that any of the three processes can start to execute first and context switching can happen between these processes at any arbitrary time and in any arbitrary order. Which of the following patterns is/are possible to be generated as an outcome of the execution of these three processes?
  1. A
    $*###
  2. B
    $#*##
  3. C
    $###
  4. D
    $###
Practise the full 2026-AN paper
Challenge a friend: WhatsApp Telegram
From RENYXERAPractise this subject in the exam simulatorTimed, GATE-style tests with analytics that find your weak topics.
Practise more on Concurrency & Synchronization (Semaphores, Mutex, Monitors, Locks)Timed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group