Computer Science 322
Operating Systems

Mount Holyoke College
Spring 2008


Lab 4: Bounded Buffer with Semaphores
Due: 10:00 AM, Monday, March 24, 2008


We have another relatively short lab assignment as we approach spring break and you work on a few more substantial lecture assignments. Please work individually on this lab assignment.

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.

See the examples and man pages for more information on POSIX threads and POSIX semaphores. Please don't hesitate to ask questions!

Submission and Evaluation

All necessary files should be submitted using turnin on the cluster head node under lab4. Include a Makefile to allow easy compilation of the C program.