Question 47

The producer and Consumer processes share the following Variables:

The producer and Consumer processes share the following Variables: int n, Semaphore M = 1 Semaphore E = n Semaphore F = 0 The consumer process must execute ______ and ______ before removing an item from buffer.
  1. ASignal (M), Signal (F)
  2. BSignal (M), Wait (F)
  3. CSignal (F), Wait (M)
  4. DWait (F), Wait (M)
Show answerHide answer

Correct answer: (D) Wait (F), Wait (M)

Explanation

A consumer first does wait(F) to make sure a full slot exists, then wait(M) for mutual exclusion on the buffer, and only then removes the item.

From DSSSB TGT Computer Science Practice Set 2

This is question 47 of DSSSB TGT Computer Science Practice Set 2. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.