Correct Answer - Option 4 : wait(F), wait(M)
In producer- consumer problem, producer can only produce the items when there is space in the buffer, means it has to wait for the consumer to consume the items. Similarly, consumer can consume the item only when producer produces it.
Given, M = 1, E = n and F =0
Here, semaphore M is for mutual exclusion, semaphore E is for empty space in buffer , semaphore F is used to define the space filled by the producer.
code for producer side:
Code for consumer side: