GATE CSE 2024 | Set 2 | Question: 36 | OS | Solved GATE CS PYQS

preview_player
Показать описание
Consider 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 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?

runs first and prints
runs next and prints
runs first and prints
runs next and prints
runs first and prints
does not print anything (deadlock)
runs first and prints
does not print anything (deadlock)

#gatecspyqs #gatecse #gatecs2024



Рекомендации по теме