GATEverse Practice, past papers & mock tests
GATE 2021 · Set-2
Operating SystemsProcess Management-IIhardMSQ2 marks
Consider the following multi-threaded code segment (in a mix of C and pseudo-code), invoked by two processes P1 and P2, and each of the processes spawns two threads T1 and T2:
c
int x = 0;  // global
Lock L1;    // global
main() {
 create a thread to execute foo();  // Thread T1
 create a thread to execute foo();  // Thread T2
 wait for the two threads to finish execution;
 printf(x);}

foo() {
 int y = 0;
 Acquire L1;
 x = x + 1;
 y = y + 1;
 Release L1;
 printf(y);}
Which of the following statement(s) is/are correct?

Select every correct option.

Save your progress

Related Operating Systems PYQs