Computer Science - Operating Systems Concepts - Discussion

Discussion Forum : Operating Systems Concepts - Section 2 (Q.No. 13)
13.
Producer consumer problem can be solved using
semaphores
event counters
monitors
all of the above
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
11 comments Page 1 of 2.

Mandeep said:   1 decade ago
Semaphores are allso solve the problem of producer and consumer.

Girraj said:   1 decade ago
What is Producer consumer problem can anybody explain?

Priyanka said:   1 decade ago
The producer-consumer problem (also known as the bounded-buffer problem) is a classic 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.
(3)

Vikas awasthy said:   1 decade ago
Give some suggestion about event counters and monitors as-well.

Abhayraj SN said:   9 years ago
@Priyanka.

Nice explanation, Thank you so much!

Rainee.jain96@gmail.com said:   8 years ago
Nice, Thanks All.

Shubham srivastava said:   8 years ago
Thanks @Priyanka.

Shubham srivastava said:   8 years ago
Counter is basically an integer which is incremented by 1 whenever producer produces provided counter size is lesser than the buffer size. Also, the counter is decremented by 1 whenever consumer reads from buffer provided counter is not 0.

Krishnendu said:   8 years ago
@Priyanka. Superb explanation.

Teja shanmukh said:   6 years ago
Awesome explanation, thanks @Priyanka.


Post your comments here:

Your comments will be displayed after verification.