The George Washington University
School of Engineering and Applied Science
Department of Electrical Engineering and Computer Science
CSci 51 -- Fall 1998
Project #8
Due Date: start of class, Thursday, 12 November 1998

This project involves five students over a weekend; they are either eating or sleeping. That is it. The five students are sitting at a large round table in the student union building. They eat at the table and they sleep at the table (these student are not in condition to leave the table after eating). This project simulates their behaviour over the weekend. The weekend is 48 hours long. Use one second on the computer to represent one hour of weekend time. The simulation rules are as follows:

     o  There are five students -- one task per student
     o  There are five chopsticks
     o  There is only one chopstick between each student
     o  A student must "pick_up" two chopsticks to eat
        (only the chopsticks next to the student)
     o  A student must "put_down" two chopsticks after eating
     o  Only one student can have a chopstick at a time
     o  There is an huge supply of food in the center of the table
        (enough for the entire weekend)
     o  Students eat for periods of 1, 2, or 3 hours at a time
        (consecutively)
     o  Students sleep for periods of 1, 2, 3, or 4 hours at a time
        (consecutively)
     o  At no time can all five students hold just one chopstick
        and be waiting for a second chopstick (deadlock)
     o  Students must be allowed to complete their eating and
        sleeping cycle even after the 48 hour period is over
        (they had a terrible prior week)
     o  All task communication is by message passing only
     o  Tasks are given their name and number after they are running

This project uses the DELAY statement in Ada. The DELAY statement uses variables of SUBTYPE Duration as input. The output of the program is in the following format:

     Student Version of Dining Philosophers
       This program uses five diner tasks.
       <Place other descriptive information here>

     Diner 1 -> Nikki is eating.
     Diner 1 -> Nikki finished eating.
     Diner 1 -> Nikki is sleeping.
     Diner 1 -> Nikki is finished sleeping.
     .
     .
     Passing quit to diner tasks
     Diner 1 -> Nikki is finished sleeping.
     Diner 1 -> Nikki TASK is terminating
     .
     .
     All tasks have quit.  Program completed.