Consider a multi-threaded program with two threads and . The threads share two semaphores: (initialized to 1) and (initialized to 0). The threads also share a global variable (initialized to 0). 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 and execute concurrently?
