Q-2)
for consumer part
if (count==0)
consumer understands that buffer is full,But before consumer going to sleep It got preempted and went to the Ready Queue
when producer produce an item and make Count=1,it will think consumer is blocked and try to wake up the consumer.
But actually Consumer is not Blocked it is in ready queue
After Some time Consumer come and Go to sleep[as before preemption it had seen that buffer is empty]
producer think that he has woken up consumer and consumer is busy in consuming its produced item and consumer is waitinng for producer wakeup call
After sometime when buffer is full,producer went to sleep thinking that when buffer is empty consumer will wake him up .And consumer is still waiting for producer wakeup call
So now Both are sleeping nd deadlock happens.
After some