GATE CS 2022 (Forenoon) — Question 19

Operating Systems (OS)Concurrency & Synchronization (Semaphores, Mutex, Monitors, Locks)MCQ1 mark · −1/3 if wrongMedium

Consider the following threads, \(T_1\), \(T_2\) and \(T_3\) executing on a single processor, synchronized using three binary semaphore variables, \(S_1\), \(S_2\) and \(S_3\), operated upon using standard wait( ) and signal( ). The threads can be context switched in any order and at any time.
c
1// T1
2while (true) {
3  wait (S_3);
4  print ("C");
5  signal (S_2);
6}
7
8// T2
9while (true) {
10  wait (S_1);
11  print ("B");
12  signal (S_3);
13}
14
15// T3
16while (true) {
17  wait (S_2);
18  print ("A");
19  signal (S_1);
20}
21
Which initialization of the semaphores would print the sequence BCABCABCA.....?
  1. A
    \(S_1 = 1; S_2 = 1; S_3 = 1\)
  2. B
    \(S_1 = 1; S_2 = 1; S_3 = 0\)
  3. C
    \(S_1 = 1; S_2 = 0; S_3 = 0\)
  4. D
    \(S_1 = 0; S_2 = 1; S_3 = 1\)
Practise the full 2022-FN paper
Challenge a friend: WhatsApp Telegram
Recommended book · affiliate linkOperating System Concepts (Galvin)Scheduling, synchronisation, deadlocks, memory and file systems.
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