CS 3733 Operating Systems, Fall 2007 Assignment 5 Comments
Comments on the bounded buffer of assignment 5.
Comments on the rest of assignment 5.
- Your Part 2 should not require that there are an equal number of
producers and consumers.
- Be sure to look through the entire assignment, even if there is nothing
written on the front.
- A function that is used as a thread must return a pointer and have a
single pointer parameter, even if that parameter is not used.
- For Part 2, when do the consumers stop consuming? There are 2 ways
to do this.
- Tell each consumer exactly how many items to consume.
This is easy when the number of producers equals the
number of consumers and most people assumed this, with
each producer and consumer handling max items.
If the number of producers and consumers is different,
it is a little more difficult, and nobody did it right.
The following does not work:
    nprod = number of producers
    ncon = number of consumers
    Each producer handles max/npord items
    Each consumer handles max/ncon items
What happens when max = 8, nprod = 2, and
ncon = 3?
- Tell the consumers to stop when the producers have finished
and the bounded_buffer is empty. This requires some tricky
synchronization.
- Need a protected shared flag, producersDone
- remove in bounded_buffer needs to return if
the buffer is empty and producersDone is true.
This needs to be done before wait(full).