Each of a set of n processes executes the following code using two semaphores…
GATE · 2020 · CS · Computer Science & IT
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
Each process executes its own CODE SECTION P before the synchronization code below.
wait(a);
count = count + 1;
if (count == n) signal(b);
signal(a);
wait(b);
signal(b);CODE SECTION Q
Each process begins its own CODE SECTION Q only after completing the synchronization code above.
What does the code achieve?
- A.
It ensures that no process executes
CODE SECTION Qbefore every process has finishedCODE SECTION P. - B.
It ensures that at most two processes are in CODE SECTION Q at any time.
- C.
It ensures that all processes execute
CODE SECTION Pmutually exclusively. - D.
It ensures that at most
n−1processes are inCODE SECTION Pat any time.
Attempted by 168 students.
Show answer
Correct answer: A
Explore the full course: Iocl Engineers Officers Grade A Paper 2