UNIVERSITY OF WISCONSIN-MADISON
Computer Sciences Department
CS 537
Fall 2012
Barton Miller
Programming Assignment #2
(Due Wednesday, October 24, at 5pm)

A list of hints and helps for this assignment is now available. It will be updated as I get more questions from the class.


Shared Memory Producer/Consumer Program

The goal of this assignment is to get experience in writing a program that actually runs in parallel on Linxu using threads (pthreads) and synchronization. You will write a program with four threads, structured like:


Producer/Consumer

Synchronization and Communication

The threads will communicate through shared memory using pthreads synchronization. Tristan Ravitch prepared a great tutorial from a previous semester on how to use pthreads to create threads and synchronize.

Compiling Your Program

See the thread tutorial for compiling instructions.

Program Details

  1. Your program will create four pthread threads. Details on how to create threads is in Tristan's tutorial. Note that you will not be using fork and exec.
  2. Thread Reader will read in each input line. If the line is longer than 63 characters, it will truncate it to 63 characters (plus the null byte at the end). Just throw away (flush to end of line) any extra characters.
  3. You will read from stdin and write to stdout.
  4. See the manual page entry for the function "index" to making writing Munch1 easier.
  5. See the manual page entries for "islower" and "toupper" to making writing Munch2 easier. (Read these function names as "is lower" and "to upper".
  6. Thread Writer will count the number of lines and print this number to stdout.
  7. You should develop a module that implements a queue of character string buffers.
  8. Threads should terminate when there is no more input (end of file).

Deliverables

To turn in your programs, copy all .C and .h files, the Makefile and a README (as for Program 1) into ~cs537-1/handin/your_login/prodcons, along with your Makefile.


Last modified: Tue Oct 9 10:05:33 CDT 2012 by bart