Skip to content

GATE CS Concurrency and Synchronization questions

Practise Concurrency and Synchronization questions for GATE CS. Explore official PYQs and original topic-wise quizzes, check answers and view available solutions. Free, no sign-in.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

20 on this page
Official PYQ2026Operating SystemConcurrency and SynchronizationMSQ · 2 marks
Consider three processes P1, P2\text{P1, P2}, and P3\text{P3} running identical code, as shown in the pseudocode below. A\text{A} and B\text{B} are two binary semaphores initialized to 11 and 00, respectively. X\text{X} is a shared variable initialized to 00. Each line in the pseudocode is executed atomically. Pseudocode of P1, P2, and P3 …
Official PYQ2024Operating SystemConcurrency and SynchronizationMSQ · 2 marks
​​​​​Consider a multi-threaded program with two threads T1\mathrm{T} 1 and T2\mathrm{T} 2. The threads share two semaphores: s1s1 (initialized to 11) and s2s2 (initialized to 00). The threads also share a global variable x\mathrm{x} (initialized to 00). The threads execute the code shown below. //code of T 1 wait (s1); x = x+1; print (x); …
Official PYQ2023Operating SystemConcurrency and SynchronizationMCQ · 2 marks
Consider the two functions incr\textsf{incr} and decr\textsf{decr} shown below. incr(){ decr(){ wait(s); wait(s); X = X+1; X = X-1; signal(s); signal(s); } } There are 55 threads each invoking incr\textsf{incr} once, and 33 threads each invoking decr\textsf{decr} once, on the same shared variable X\mathrm{X}. The initial value of X\mathrm{X} is …
Official PYQ2022Operating SystemConcurrency and SynchronizationMCQ · 1 mark
Consider the following threads, T1,T2,\text{T}_{1}, \text{T}_{2}, and T3\text{T}_{3} executing on a single processor, synchronized using three binary semaphore variables, S1,S2,\text{S}_{1}, \text{S}_{2}, and S3,\text{S}_{3}, operated upon using standard wait()\textsf{wait}() and signal().\textsf{signal}(). The threads can be context switched in any order and at any …
Official PYQ2021Operating SystemConcurrency and SynchronizationMSQ · 2 marks
Consider the following pseudocode, where S\textsf{S} is a semaphore initialized to 55 in line #2\#2 and counter\textsf{counter} is a shared variable initialized to 00 in line #1\#1. Assume that the increment operation in line #7\#7 is not\textit{not} atomic. 1. int counter = 0; 2. Semaphore S = init(5); 3. void parop(void) 4. { 5. wait(S); 6. …
Official PYQ2020Operating SystemConcurrency and SynchronizationMCQ · 2 marks
Each of a set of nn processes executes the following code using two semaphores aa and bb initialized to 11 and 00, respectively. Assume that count\text{count} is a shared variable initialized to 00 and not used in CODE SECTION P. CODE SECTION P\begin{array}{|c|} \hline \textbf{CODE SECTION P} \\ \hline \end{array} wait(a); count=count+1; if (count==n) …
Official PYQ2019Operating SystemConcurrency and SynchronizationNAT · 1 mark
Consider three concurrent processes P1,P2P_1, P_2 and P3P_3 as shown below, which access a shared variable DD that has been initialized to 100.100. P1P2P3::::::D=D+20D=D−50D=D+10::::::\begin{array}{|c|c|c|} \hline P_1 & P_2 & P_3 \\ \hline : & : & : \\ : & : & : \\ D=D+20 & D=D-50 & D=D+10 \\ : & : & : \\ : & : & : \\ \hline \end{array} …
Official PYQ2018Operating SystemConcurrency and SynchronizationMCQ · 2 marks
Consider the following solution to the producer-consumer synchronization problem. The shared buffer size is NN. Three semaphores emptyempty, fullfull and mutexmutex are defined with respective initial values of 0,N0, N and 11. Semaphore emptyempty denotes the number of available slots in the buffer, for the consumer to read from. Semaphore fullfull …
Official PYQ2017Operating SystemConcurrency and SynchronizationMCQ · 1 mark
A multithreaded program PP executes with xx number of threads and uses yy number of locks for ensuring mutual exclusion while operating on shared memory locations. All locks in the program are non-reentrant, i.e., if a thread holds a lock ll, then it cannot re-acquire lock ll without releasing it. If a thread is unable to acquire a lock, it …
Official PYQ2016Operating SystemConcurrency and SynchronizationMCQ · 1 mark
Consider the following proposed solution for the critical section problem. There are nn processes : P0....Pn−1P_0....P_{n-1}. In the code, function pmax\text{pmax} returns an integer not smaller than any of its arguments .For all i,t[i]i,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 …
Official PYQ2016Operating SystemConcurrency and SynchronizationMCQ · 1 mark
Consider the following two-process synchronization solution. …
Official PYQ2016Operating SystemConcurrency and SynchronizationNAT · 1 mark
Consider a non-negative counting semaphore SS. The operation P(S)P(S) decrements SS, and V(S)V(S) increments SS. During an execution, 2020 P(S)P(S) operations and 1212 V(S)V(S) operations are issued in some order. The largest initial value of SS for which at least one P(S)P(S) operation will remain blocked is _______
Official PYQ2015Operating SystemConcurrency and SynchronizationNAT · 1 mark
The following two functions P1P1 and P2P2 that share a variable BB with an initial value of 22 execute concurrently. P1() { P2(){ C = B - 1; D = 2 * B;  B = 2 * C; B = D - 1;}}\begin{array}{|l|l|}\hline \text{P1() \{ } & \text{P2()\{} \\ \text{ C = B - 1;} & \text{ D = 2 * B; } \\ \text{ B = 2 * C;} & \text{ B = D - 1;} \\ \text{\}} & \text{\}} \\ \hline \end{array} The number of …
Official PYQ2015Operating SystemConcurrency and SynchronizationMCQ · 1 mark
Two processes XX and YY need to access a critical section. Consider the following synchronization construct used by both the processes …
Official PYQ2014Operating SystemConcurrency and SynchronizationMCQ · 1 mark
Consider the procedure below for the Producer-Consumer problem which uses semaphores: semaphore n = 0; semaphore s = 1; void producer() { while(true) { produce(); semWait(s); addToBuffer(); semSignal(s); semSignal(n); } } void consumer() { while(true) { semWait(s); semWait(n); removeFromBuffer(); semSignal(s); consume(); } } Which one of the following is …
Official PYQ2013Operating SystemConcurrency and SynchronizationMCQ · 1 mark
A certain computation generates two arrays a and b such that a[i]=f(i)a[i] = f(i) for 0≤i<n0 \leq i < n and b[i]=g(a[i])b[i] = g(a[i]) for 0≤i<n0 \leq i < n. Suppose this computation is decomposed into two concurrent processes XX and YY such that XX computes the array aa and YY computes the array bb. The processes employ two binary semaphores RR …
Official PYQ2013Operating SystemConcurrency and SynchronizationMCQ · 1 mark
A shared variable xx, initialized to zero, is operated on by four concurrent processes W,X,Y,ZW, X, Y, Z as follows. Each of the processes WW and XX reads xx from memory, increments by one, stores it to memory, and then terminates. Each of the processes YY and ZZ reads xx from memory, decrements by two, stores it to memory, and then …
Official PYQ2012Operating SystemConcurrency and SynchronizationMCQ · 1 mark
Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of memory location XX, increments it by the value ii, and returns the old value of XX. It is used in the pseudocode shown below to implement a busy-wait lock. LL is an unsigned integer shared variable initialized to 00. The value of 00 corresponds to lock …
Official PYQ2010Operating SystemConcurrency and SynchronizationMCQ · 1 mark
The following program consists of 33 concurrent processes and 33 binary semaphores. The semaphores are initialized as S0=1,S1=0S0=1, S1=0 and S2=0.S2=0. …
Official PYQ2010Operating SystemConcurrency and SynchronizationMCQ · 1 mark
Consider the methods used by processes P1P1 and P2P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1S1 and S2S2 are randomly assigned. …