GATEverse
← GATE CSE 2024 Set 2

Q36

MSQ2 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); wait (s2); signal(s1); // code of T2 wait (s1); x= x+1; print (x) ; signal (s2); signal (s1); Which of the following outcomes is/are possible when threads T1\mathrm{T} 1 and T2\mathrm{T} 2 execute concurrently?

Sign in to save attempts.

Loading…