CSCI-7645: Practice Problem Set 3b
Fairleigh Dickinson University Vancouver
Spring 2025
Problems
1. Consider the two implementations of the producer consumer problem with POSIX threads and mutex
provided in Webcampus. Recall that the first version does not use POSIX condition variables whereas
the second version uses them. Modify both implementations such that the following parameters can
be specified by the user using command line arguments:
• the number of producer threads,
• the number of seconds each producer thread must sleep after producing a unit (i.e., item),
• the number of consumer threads,
• the number of seconds each consumer thread must sleep after consuming a unit,
• the minimum number of units that must be in the buffer at any time, and
• the maximum number of units that must be in the buffer at any time.