Q36
MSQ2 marksOperating systemsConsider a multi-threaded program with two threads and . The threads share two semaphores: (initialized to ) and (initialized to ). The threads also share a global variable (initialized to ). The threads execute the code shown below.
// code of T1
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?
Sign in to save attempts.
Keys: A–D or 1–4 choose, Enter checks, ← → move between questions.
Solutions and discussion are hidden while you attempt this question. They open once you check or show the answer.