Lecture 15
Lecture 15
There is one Producer in the producer-consumer problem, Producer is producing some items,
whereas there is one Consumer that is consuming the items produced by the Producer. The same
memory buffer is shared by both producers and consumers which is of fixed-size.
The task of the Producer is to produce the item, put it into the memory buffer, and again start
producing items. Whereas the task of the Consumer is to consume the item from the memory buffer.
o The producer should produce data only when the buffer is not full. In case it is found that the
buffer is full, the producer is not allowed to store any data into the memory buffer.
o Data can only be consumed by the consumer if and only if the memory buffer is not empty.
In case it is found that the buffer is empty, the consumer is not allowed to use any data from
the memory buffer.
o Accessing memory buffer should not be allowed to producer and consumer at the same time.
COUNT