Question:

Arrange the following semaphore operations in the correct sequence for producer process in bounded-buffer problem using semaphores (empty, full and mutex).
• [A.] Signal (full) -- indicating that the new item has been produced and added to the buffer
• [B.] Wait (empty) -- checks if there is space in the buffer
• [C.] Produce an item and store it in the buffer
• [D.] Wait (mutex) -- enters the critical section to insert the item safely
• [E.] Signal (mutex) -- leaves the critical section after inserting the item
Choose the correct answer from the options given below:

Show Hint

Producer order: Wait(empty) → Wait(mutex) → Produce → Signal(mutex) → Signal(full).
Updated On: Jun 5, 2026
  • A, C, E, D, B
  • C, B, A, D, E
  • B, D, C, E, A
  • B, C, D, E, A
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Concept: Producer-consumer problem uses semaphores:
empty: counts empty slots
full: counts filled slots
mutex: ensures mutual exclusion

Step 1:
Check for empty space. \[ \text{Wait(empty)} \Rightarrow B \] Ensures buffer has space.

Step 2:
Enter critical section. \[ \text{Wait(mutex)} \Rightarrow D \] Ensures exclusive access.

Step 3:
Produce and insert item. \[ \Rightarrow C \]

Step 4:
Exit critical section. \[ \text{Signal(mutex)} \Rightarrow E \]

Step 5:
Update full semaphore. \[ \text{Signal(full)} \Rightarrow A \] Final Sequence: \[ B \rightarrow D \rightarrow C \rightarrow E \rightarrow A \] \[ \boxed{(3)} \]
Was this answer helpful?
0
0

Top CUET PG Operating Systems Questions

View More Questions