Computer Sciences > Gate 2020 > semaphores
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.

Correct : a

Similar Questions

A palindrome is a word that reads the same forwards and backwards. In a game of words, a player has the following two plates painted with letters. From...
#1 MCQ
Which number does not belong in the series below? 2, 5, 10, 17, 26, 37, 50, 64
#4 MCQ
Choose the word that is opposite in meaning to the word “coherent”.
#5 MCQ

Related Topics

No tags found

Unique Visitor Count

Total Unique Visitors

Loading......