OS Producer Consumer Problem
by: Victoria Albanese (7 months ago)



Project #2815

97 Views
Description

The one of the basic multi-threading problems in operating systems is the producer consumer problem.  In this issue, there are one or many producers, and one or many consumers.  The producers make some resource and store it somewhere, and the consumers access that resource and then consume it.  The problem is all of these processes would need to touch the same data, and that could result in contamination of data if the data manipulation is not regulated.

Here, we have one producer and multiple consumers.  The producer flips a 4 sided coin, and based on the result decides to make a donut of one of four flavors.  It then puts the donut in the appropriate flavor queue, which has a preset number of slots.  The consumer flips a four sided coin and decided which donut it wants to take, and does this enough times to order 10 dozen donuts.  Semaphores are used to make sure that each process runs its critical section alone, so that there is no data contamination.

However, it is possible, in this process for deadlocks to occur.  For example, if a producer wants to make a glazed donut, but there are no slots left, and no consumers want glazed donuts, the producer will stop producing donuts, and that process will hang.  Likewise, if a consumer wants a blueberry donut, but there are none left, and the producer doesn't make any more, then that process will hang.

In this experiment, we vary both the number of slots in each flavor queue, and the number of consumers vying for donuts to see which combination yields the least deadlocks.  Each data point represents the number of runs that resulted in a deadlock out of 100 runs.


Fields
Name Units Type
Consumers
None
Number
Slots
None
Number
Deadlocks
None
Number
Formula Fields
Contribute Data
Please log in to contribute data

OS Producer Consumer Problem

Project #2815 on iSENSEProject.org


Description

The one of the basic multi-threading problems in operating systems is the producer consumer problem.  In this issue, there are one or many producers, and one or many consumers.  The producers make some resource and store it somewhere, and the consumers access that resource and then consume it.  The problem is all of these processes would need to touch the same data, and that could result in contamination of data if the data manipulation is not regulated.

Here, we have one producer and multiple consumers.  The producer flips a 4 sided coin, and based on the result decides to make a donut of one of four flavors.  It then puts the donut in the appropriate flavor queue, which has a preset number of slots.  The consumer flips a four sided coin and decided which donut it wants to take, and does this enough times to order 10 dozen donuts.  Semaphores are used to make sure that each process runs its critical section alone, so that there is no data contamination.

However, it is possible, in this process for deadlocks to occur.  For example, if a producer wants to make a glazed donut, but there are no slots left, and no consumers want glazed donuts, the producer will stop producing donuts, and that process will hang.  Likewise, if a consumer wants a blueberry donut, but there are none left, and the producer doesn't make any more, then that process will hang.

In this experiment, we vary both the number of slots in each flavor queue, and the number of consumers vying for donuts to see which combination yields the least deadlocks.  Each data point represents the number of runs that resulted in a deadlock out of 100 runs.



Fields
Name Units Type of Data
Consumers
None
Number
Slots
None
Number
Deadlocks
None
Number

Our Data
Name(s): ______________________________________
Date: _________________________________________

Consumers Slots Deadlocks