CS 284 Operating Systems
Programming Assignment #7
Due: 2/26/2001 - Class Time
Write a C program that produces enough neatly formatted out to demonstrate
that it has correctly performed the following:
- main() creates 5 producer threads and 2 consumer threads and then waits
(joins) until they have all exited (thr exit).
- main() reports how many widgits each producer produced (reported back via
a return value) and how many widgits each consumer consumed (reported back
via a return value).
- The producers should produce a TOTAL of 50 widgits and then exit.
- The consumers should of course consume all 50 and then exit.
- A producer should produce an additional widgit every 1 - 5 random seconds
(note: rand is NOT MT-Safe).
- A consumer should consume an additional widgit every .1 - .8 random seconds
- Producers place widgits INTO and consumers remove widgits FROM an area large
enough to hold a maximum of 10 widgits (Buffer).
Program design issues:
- Consumers should cond_wait(...) if there are no widgits available to be
consumed
- Producers should cond_wait(...) if the Buffer is full.
- Producers and consumers should cond_signal eachother to alert a waiting
thread to wake up.
- No 'shared resource' should be accessed without the benefit of a mutex_lock().
Sample output results
=================================================================
You should use the 'script' command to capture all necessary information for
handin.