I am confused in understanding the complete flow of producer-consumer problem in following schenerio.
Let currently buffer in empty and there is no data in there,and let some how consumer starts executing and will make F = -1, and go to sleep. Now Producer comes into execution inserts data into buffer comes out of critical section and will finally makes F=0 and wakes up consumer.
Now just before producer executing again, consumer start executing from line where it goes to sleep i.e wait(F), i mean now F is 0 again means consumer will perform wait(F) goes to sleep again isn’t.
Note:- F is the counting semaphore helping consumer to determine if there is even a single buffer full to consume from it.