George Mason University
CS571 - Spring 2001                         PROJECT ASSIGNMENT #1
Professor: Dr. Tan N. Nguyen
Email: tnguy1@cs.gmu.edu

1. INTRODUCTION:
The programming project is an important aspect of the course since it will give students the opportunity to immediately apply the techniques being taught.  This project is intended to reinforce the concepts learned in chapters 6, 7, and 8.  From these chapters, you should have learned the concept of process management of an operating system.  A goal of process management is to allow cooperating processes (or threads) to share a logical address space.  However, concurrent access to shared data may result in data inconsistency and other issues such as deadlocks and starvations.  Your assignment is to study a mechanism that ensures data consistency allowing concurrently execution of cooperating processes or threads.
You may choose to work on any classical (well-known) problems discussed in section 7.6, problems 7.10, 7.11, or any other synchronization problems that you have known, or from your own discovery when using synchronization tools, e.g., semaphores, monitor, Java synchronization, etc.

2. ASSIGNMENT DESCRIPTION:
Your assignment is to (1) describe a problem mentioned above, (2) propose a solution, and then (3) implement the solution in a computer programming language on an operating system.  Since this semester we have a "very diverse computer science background" class, you may choose any programming language or any operating system.  You must arrange enough time and instructions to the instructor or T.A. to examine your work if the chosen operating system is not a UNIX or Windows system.  There is a "default" project for you to choose if you would not like to create your own project.  Refer to this  http link for the default project:  http://classweb.gmu.edu/tnguy1/cs571s01/defaultproject1.htm.  For more information on threads and Java thread, please follow this link: http://www.ibiblio.org/javafaq/course/week11/index.html

3. DELIVERABLES:
The deliverables should include a hard copy final report and a floppy disk (in Windows format) containing the final report, your program code and instructions for the instructor or T.A. to install and test your program.

The final report should follow this outline:

  1. title/author/abstract - approximately 1/2 page. The abstract should indicate the purpose of your project. The abstract should also indicate your learning objective in working on your project 
  2. project description - 4 pages that includes one or more diagrams illustrating the structure of the program. This description should allow a knowledgeable reader to understand the overall architecture of your project.
  3. summary - approximately 1/2 page indicating what you learned from this project and what extensions or variations of this project might be possible.
  4. coding and output - a list of your program compilation, an output of your program

4.  DUE DATE:

    Thursday, March 30, 2001.  Please submit your project to the T.A.

DEFAULT PROGRAMMING PROJECT #1 :
The purpose of this project is to give you some practical experience in the use of synchronization primitive.

ADVANCE PREPARATION:
You should complete the following steps before working on this project:

  1. Step 1: Study the Java code on the Producer-Consumer problem for chapters 5 and 7
  2. Step 2: Develop a plan to use a computer language, e.g., Java, C, C++, etc. to implement the following problem
  3. Step 3: Implement the following problem.
PROBLEM:
Create two threads (that is NOT thread-safe), producer (P) and consumer (C).  P produces items and inserts them into a bounded buffer; C retrieves items from the buffer and outputs them. Each item must be retrieved exactly once, and all items are to be retrieved in the same order in which they were inserted. Set up a timer mechanism to report elapsed and CPU time consumed by the P/C during the experiment.

The producer is to generate the sequence of items 1, 2, ... , 100, and insert them into the buffer by this schedule:
5:delay(15):10:delay(15):15:delay(15):20:delay(15):50
Where the numbers indicate how many items are inserted into the buffer and the delays are in seconds.

The consumer is to consume items according to the following schedule:
delay(15):5:delay(15):20:delay(15):15:delay(15):60

The producer completes when all 100 items have been inserted into the buffer. The consumer completes when it has made 100 retrievals and printed them. The Producer-Consumer (PC) system completes when both P and C complete.

  1. Program a circular buffer of capacity 5 elements between producer and consumer. Use no semaphores or message queue or other synchronization solution. Use only shared memory. Run the PC to completion 5 times. For each run, record the output of the consumer and the total real time and CPU time.  If there are differences between the runs, please account for the differences. Summarize your findings and draw conclusions.
  2. Repeat the previous process with your own solution that must be thread-safe.  Do not use semaphore to synchronize P and C.
  3. What did you learn from the experiment?