1
GATE CSE 2006
MCQ (Single Correct Answer)
+2
-0.6
Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three and S be a binary semaphore with the usual P and V functions. Consider the following C implementation of a barrier with line numbers shown on left.
The above implementation of barrier is incorrect. Which one of the following is true?
void barrier (void) {
1: P(S);
2: process_arrived++;
3: V(S);
4: while (process_arrived !=3);
5: P(S);
6: process_left++;
7: if (process_left==3) {
8: process_arrived = 0;
9: process_left = 0;
10: }
11: V(S);
}
The variables process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally.The above implementation of barrier is incorrect. Which one of the following is true?
2
GATE CSE 2003
MCQ (Single Correct Answer)
+2
-0.6
Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T. The code for the processes P and Q is shown below.
Process P:
Process Q:
Process P:
while(1){
W:
Print '0';
Print '0';
X:
}
Process Q:
while(1){
Y:
Print '1';
Print '1';
Z:
}
Synchronization statements can be inserted only at points W, X, Y, and Z.Which of the following will always lead to an output starting with 001100110011
3
GATE CSE 2003
MCQ (Single Correct Answer)
+2
-0.6
Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T. The code for the processes P and Q is shown below.
Process P:
Process Q:
Process P:
while(1){
W:
Print '0';
Print '0';
X:
}
Process Q:
while(1){
Y:
Print '1';
Print '1';
Z:
}
Synchronization statements can be inserted only at points W, X, Y, and Z.Which of the following will ensure that the output string never contains a substring of the form 01n0 or 10n1 where n is odd?
4
GATE CSE 2001
MCQ (Single Correct Answer)
+2
-0.6
Consider Peterson’s algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process is shown below.
Repeat
flag[i]=true;
turn=j;
while (P) do no-op;
Enter critical section, perform actions, then
exit critical section
Flag[i]=false;
Perform other non-critical section actions.
Until false;
For the program to guarantee mutual exclusion, the predicate P in the while loop should be Questions Asked from Synchronization and Concurrency (Marks 2)
Number in Brackets after Paper Indicates No. of Questions
GATE CSE 2024 Set 1 (2)
GATE CSE 2023 (1)
GATE CSE 2021 Set 2 (2)
GATE CSE 2020 (1)
GATE CSE 2013 (2)
GATE CSE 2012 (1)
GATE CSE 2010 (1)
GATE CSE 2009 (1)
GATE CSE 2008 (1)
GATE CSE 2007 (1)
GATE CSE 2006 (3)
GATE CSE 2003 (2)
GATE CSE 2001 (1)
GATE CSE 1997 (1)
GATE CSE 1996 (2)
GATE CSE 1992 (1)
GATE CSE 1990 (1)
GATE CSE 1987 (1)
GATE CSE Subjects
Theory of Computation
Operating Systems
Algorithms
Database Management System
Data Structures
Computer Networks
Software Engineering
Compiler Design
Web Technologies
General Aptitude
Discrete Mathematics
Programming Languages