Problem for Practice

Question 1: Processes P1 and P2 have a producer-consumer relationship, communicating by the use of a set of shared buffers.

P1: repeat
Obtain an empty buffer
Fill it
Return a full buffer
forever
P2: repeat
Obtain a full buffer
Empty it
Return an empty buffer
forever

Increasing the number of buffers is likely to do which of the following? [ISRO CS 2018]

I. Increase the rate at which requests are satisfied (throughput).

II. Decrease the likelihood of deadlock .

III. Increase the ease of achieving a correct implementation.

 (A) Ill only

 (B) II only

(C) I only 

(D) II and III only

Solution: Increasing the size of the memory allocated to the process or increasing buffer requirement does not affect the likelihood  of the
deadlock and doesn't affect the implementation of the system. It can increase the rate at which the requests are satisfied(throughput) larger
will be the size of the buffer, larger will be throughput. Therefore the only statement correct is I. Hence option (C) is correct.

Producer Consumer Problem in C

Concurrency is an important topic in concurrent programming since it allows us to completely understand how the systems work. Among the several challenges faced by practitioners working with these systems, there is a major synchronization issue which is the producer-consumer problem. In this article, we will discuss this problem and look at possible solutions based on C programming.

Similar Reads

What is the Producer-Consumer Problem?

The producer-consumer problem is an example of a multi-process synchronization problem. The problem describes two processes, the producer and the consumer that share a common fixed-size buffer and use it as a queue....

Problem for Practice

Question 1: Processes P1 and P2 have a producer-consumer relationship, communicating by the use of a set of shared buffers....

Frequently Asked Question on Producer Consumer Problem – FAQs

How do we prevent a race condition in producer-consumer code?...