• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | GATE CS 2020 | Question 44

Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.
CODE SECTION P 

wait(a); count=count+1;
if (count==n) signal (b);
signal (a): wait (b) ; signal (b);

CODE SECTION Q 
What does the code achieve ?

(A)

It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P

(B)

It ensures that two processes are in CODE SECTION Q at any time

(C)

It ensures that all processes execute CODE SECTION P mutually exclusively

(D)

It ensures that at most n−1 processes are in CODE SECTION P at any time

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments