Computer Science 432
Operating Systems

Williams College
Fall 2006


Lab 4: Bounded Buffer with Semaphores
Due: 9:55 AM, Tuesday, October 17, 2006


Another short lab assignment as you prepare for the first exam and work on a the more substantial lecture assignments.

Bounded Buffer with Semaphores

Write a C program that implements the bounded buffer problem for an arbitrary number of producers and consumers (specified by command-line parameters). Use POSIX threads to create your producers and consumers and use POSIX semaphores for synchronization. Your solution should avoid the busy wait from the class examples (other than any busy waiting that might takesplace inside a semaphore wait or signal operation, which is not your fault).

Write your program in a file called prodcons.c. You may use the source code from any of the class examples as your starting point.

Submission and Evaluation

All necessary files should be submitted using turnin as a single "tar" file, lab4.tar. Include a Makefile to allow easy compilation of the C program.