
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Fall 2005 CS 440/540 Operating Systems Homework-
200 points. Individual Work Only. Due Oct 24, 2005.
Producer: The producer opens a specified file and reads the first 512 characters from a file and writes the data to shared buffer. Before writing to the buffer the producer checks to see if the buffer is empty and available for use. If the buffer is not available it waits until it becomes available. Once the producer writes the data to the buffer, the producer waits until the consumer notifies that the buffer is available, then reads the next 512 characters and writes to the shared buffer and continues until the end of the file is reached. Once the end of file is reached, the producer exits the program.
Consumer: The consumer checks if the shared buffer is full, if it is full it reads the buffer, converts all characters in the file to upper case and then writes the data to a new file, otherwise it waits until the buffer is full. After the data is read the consumer notifies the producer that the buffer is empty and then waits until the buffer is full and this process continues until the buffer contains the end-of-file character. Once the end of file is reached the consumer closes the file and exists.
The driver program must read the name of the input file and output file as command line arguments, create an instance of the producer and consumer, and pass the input file name to the producer and output file name to the consumer.
You can use the Producer/Consumer example provided in the Java Tutorial (http://java.sun.com/docs/books/tutorial/essential/threads/synchronization.html) as a starting point for this homework. Test your program with the two input files provided at http://www.cis.uab.edu/cs440/homework3/. Do not use any sleep statements inside the producer and consumer, all synchronization must be performed using wait and notify.
Submission Instructions: Create a zip/tar file of all the source code, scripts (if any), output files, and README file and email the zip/tar file as an attachment to [email protected] with the subject CS 440 Homework-3 or CS 540 Homework-3. Make sure to include instructions for compiling and running the programs. Please do not include class files in the zip/tar file.