top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

What is the famous producer consumer problem?

0 votes

What is the famous producer consumer problem, please explain with an example?

posted Jun 21, 2017 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

The Producer Consumer problem describes two processes, the producer and the consumer, who share a common, fixed size buffer know as the queue.

  1. The producer creates the data and puts it into the buffer, and start again. And At the same time, the consumer consumes the data from the buffer one piece at a time.
  2. The problem here is to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer.
  3. The solution for the producer is to either go to sleep or discard data if the buffer is full. And the next time the consumer removes an item from the buffer, it notifies the producer, who starts to fill the buffer again. In the same way, the consumer can go to sleep if it finds the buffer to be empty. The next time the producer puts data into the buffer, it notifies the consumer to start consuming the data again.
answer Jun 21, 2017 by Satish Mn
Similar Questions
0 votes

What should be the approach to create two containers in such way one container writes in shared resource and another container then consumes the content ? I want to achieve the same thing as we all did for producer consumer problem using the inter process communication.

+1 vote

What are the time complexities of some famous algorithms like below:

Binary Search :
Merge Sort:
Insertion Sort:
Quick Sort:
Selective Sort:
Finding max & min for a given set of number:

0 votes

What's the basic difference between hardware and software solutions for critical section problem? Why are they called hardware or software solution?

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.