This assignment makes use of the files contained in this zip file. You are to write a program that simulates the producer consumer synchronization pattern. Your program will create three (bounded) buffers, three producer threads, and three consumer threads. Each producer thread will be in an endless loop where it randomly chooses one of the three buffers, puts an "item" into the buffer, and then displays the contents of the buffer in the console window. Each consumer thread will be in an endless loop where it randomly chooses one of the three buffers, takes an "item" from the buffer, and then displays the contents of the buffer in the console window. Be sure that you have read Section 6.1 (pages 225-227) and Section 6.6.1 (page 240) from our operating systems textbook and Section 4.1 (pages 61-71) from "The Little Book of Semaphores".
In the zip file there is a file
The
In the zip file there are two text files,
When you work on this, first get the When you get this version of the producer-consumer problem working, you should notice that it is prone to deadlocks (when you run the program, it sometimes seems to stop several seconds before the message "Threads stopped." gets printed in the console window; that is the deadlock). Write a brief explanation of what is causing the deadlock. Also, if there is only a single producer and a single consumer but multiple buffers, can there be a deadlock? What if there are multiple producers and multiple consumers but only one buffer? Is there an easy way to avoid the deadlock situation when there are multiple producers, consumers, and buffers?
Turn in a zip file containing your explanation of the deadlock problem and your answers to the above questions, your versions of the This assignment is due Wednesday, April 8. Here are links to some Win32 API functions that you will need to use in this assignment. Here are a few more MSDN references. These are not directly related to this assignment, but you might find them informative.
|