Condition Variables
- Due:
- 11:00pm, Friday March 25, 2022
Description
For this assignment we will explore code that uses locks and condition variables to implement various forms of the producer / consumer queue. Read the README file for details about the code.
Questions
Run the
main-two-cvs-while.c
with one producer and one consumer and have the producer produce a few values. Start with a buffer of size 1 and increase it. How does the does the behavior of the program change with larger buffer sizes? (or does it?)Run the
main-two-cvs-while.c
with one producer, three consumers, a single-entry shared buffer, and each consumer pausing at pointc3
for a second. Write the command line arguments you supplied to the program.Now, run the
main-two-cvs-while.c
program as for question 2, but change the size of the shared buffer to 3. Does this make a difference in the total time? If so, describe the change.Now run the
main-two-cvs-while.c
program as for question 2, but change the location of the sleep toc6
(this models a consumer taking something off the queue and then doing something with it). Does this make a difference in the time compared to question 2? If so, describe the difference.Look at the
main-one-cv-while.c
program. Can you configure a sleep string assuming a single producer, one consumer, and a buffer of size 1, to cause a problem with this code? If so, write the sleep string and describe the problem and its cause.Now, change the number of consumers to two. Can you construct sleep strings for the producer and the consumers to cause a problem with the code? If so, write the sleep string and describe the problem and its cause.
Look at the
main-two-cvs-if.c
program. Can you cause a problem to happen in this code? Again, consider the case where there is only one consumer, and then the case where there is more than one. If you can cause a problem, describe the problem and its cause.Look at the
main-two-cvs-while-extra-unlock.c
program. What problem arises when you release the lock before executing a put or get? Can you reliably cause such a problem to happen, given the sleep string? If so, write the sleep string and describe the problem.
Turning in the Assignment
Create a text file named assignment6.txt
containing your answers to the questions. Submit your solution to the appropriate folder on D2L.
Note that your answers must be correctly numbered and only the answers must be in your submission; any answer solution that does not satisfy these requirements will be marked as a zero.