0 like 0 dislike
68 views
in Science by (1.0m points)
Write a note on producers.

1 Answer

0 like 0 dislike
by (1.0m points)
The producer–consumer problem (also known as the bounded-buffer problem) is an example of a multi-process synchronization problem.

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

The producer's job is to generate a piece of data, put it into the buffer and start again. At the same time, the consumer is consuming the data (i.e., removing it from the buffer) one piece at a time.

The problem 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.

The solution for the producer is to either go to sleep or discard data if the buffer is full. 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 wakes up the sleeping consumer.

The solution can be reached by means of inter-process communication, typically using semaphores.

An inadequate solution could result in a deadlock where both processes are waiting to be awakened. The problem can also be generalized to have multiple producers and consumers.

Related questions

0 like 0 dislike
1 answer 54 views
asked Jan 31, 2019 in Science by danish (1.0m points)
0 like 0 dislike
1 answer 49 views
asked Jan 30, 2019 in Science by danish (1.0m points)
0 like 0 dislike
1 answer 53 views
asked Jan 24, 2019 in Science by danish (1.0m points)
0 like 0 dislike
1 answer 47 views
asked Jan 23, 2019 in Science by danish (1.0m points)
0 like 0 dislike
0 answers 42 views
asked Jan 21, 2019 in Science by danish (1.0m points)
0 like 0 dislike
1 answer 93 views
asked Jan 15, 2019 in Science by danish (1.0m points)
0 like 0 dislike
1 answer 55 views
asked Jan 15, 2019 in Science by danish (1.0m points)
0 like 0 dislike
1 answer 41 views
asked Jan 15, 2019 in Science by danish (1.0m points)
0 like 0 dislike
1 answer 47 views
asked Jan 15, 2019 in Science by danish (1.0m points)
0 like 0 dislike
1 answer 62 views
asked Jan 14, 2019 in Science by danish (1.0m points)
Welcome to Free Homework Help, where you can ask questions and receive answers from other members of the community. Anybody can ask a question. Anybody can answer. The best answers are voted up and rise to the top. Join them; it only takes a minute: School, College, University, Academy Free Homework Help

19.4k questions

18.3k answers

8.7k comments

6.3k users

Free Hit Counters
...