See the assignment turn-in page (last modified on 16 July 2003) for instructions on turning in your assignment.
interface WidgetInterface { public int [] getAttributes(); }
getAttributes()
returns an a-element array; the ith array element
is the value of attribute i.
p > 0 producers make widgets and c > 0 consumers use them; both synchronize through a store:
interface StoreInterface { public void deliver(WidgetInterface widget); public WidgetInterface purchase(int [] type); }
You can find these interfaces in /export/home/class/cs-598/a7
from any cslab machine or
rockhopper.
The purchase()
argument describes the specific attribute values the desired
widget should have; the argument format is the same as the array returned by
getAttributes()
. A consumer can only buy one widget per purchase, and a
producer can only drop off one widget per delivery, but, as is usually the case
in producer-consumer problems, they can make arbitrarily many purchases and
deliveries.
Use these interfaces to implement a program that allows producers and consumers to conduct business, subject to the following constraints:
Your program should accept the following command-line options:
-a
n - each widget has n attributes.
-v
n - each attribute has n values.
-c
n - there are n consumers.
-p
n - there are n producers.
-s
n - the store has a maximum capacity of n widgets.
The default value for all options is n = 10 except for the -s
option,
where the default value is n = 100.
Note that it is possible for the system to deadlock; your program should detect deadlock and exit with an error message.
This page last modified on 22 July 2003.