Semaphore “full‟ denotes the no. of available slots in the buffer for the producer to write to.
Semaphore “empty” denotes the no. of available slots in the Buffer for the consumer to read
From.
Producer: Producer first checks whether any free slots available in the buffer of not.
Hence, wait (P) wait (full)
The producer should not produce if the buffer is full, (full) is initialized to N.
After producing an item, the item is added to buffer, hence at the end producer increases number of
Produced items.
Hence, Signal (Q) signal (empty)
Consumer: Before the consumer should take an item from buffer, it should check how many items
are present on the buffer for consumption and it should be greater than 0.
Hence, wait (R)wait (empty)
After consuming an item, on free slot is increased on buffer.
Hence, signal (S) Signal (full)
Hence ,option (C) is correct