Programming Assignment 7 - Picky Consumer Synchronization

Concurrent Programming, Summer 2003


Due Date

This assignment is due by 2:00 p.m. on Tuesday, 22 July.

See the assignment turn-in page (last modified on 16 July 2003) for instructions on turning in your assignment.

The Problem

A widget has a > 0 attributes, each attribute can be one of v > 0 values. The attributes are numbered from 0 to a - 1; the values are 0 through v - 1.

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:

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.