Need to change it so the waiter looks every second. then the
hungry transitions should not be an issue.
mike
CS 110, Dining Phils Project 1
CS 110 Intro to Computer Systems
Dining Philosophers Project
Due Date - See Calendar
30 Points for Basic Project
10 Points for Demo
Introduction
You are to implement a
Robust
Dining Philosopher's solution.
Your solution is to work in the following way:
-
You are free to use the book algorithm
(which was presented in class)
or any version of
the algorithm you might find.
-
But you
cannot
use busy waiting.
-
You are to use your Semaphore wrappers to provide necessary
semaphores.
-
You are to use Solaris shared memory.
-
You are to collaborate in groups of two
Again, we will NOT assign partners.
Each of you
is to write your own code,
but use your partner to help debug and
test your solution.
This means that you MUST contact your partner first prior to
sending help requests to the graders or tutors or cs staff.
Indicate your partner in your code comments.
-
Add to each philosopher a count of the number of times
he has eaten.
-
When each philosopher has eaten the max number of times
(max provided as an input parameter)
the philosopher stops eating (his process dies).
-
The time period for each eating session is an
input parameter (fixed for all philosophers).
While this is a neat problem, as written no one knows what the
heck is going on.
Thus you
MUST
have another process,
the Waiter,
who monitors the Philosopher's table.
Because he wants to get a good tip,
every 2 seconds the Waiter
looks at the table and determines (prints out in a horizontal
Santillo format,
-
Printout #
-
The current values in the state table
for each Philosopher, e.g., Hungry (H), Thinking (T),
Eating (E), or Done (L).
-
How many Philosophers are thinking.
-
How many Philosophers are hungry.
-
How many Philosophers are eating.
-
How many Philosophers remain at the table.
Termination
When all the Philosophers are done eating
the Waiter prints out one more time and
the program dies.
Input Parameters
There are 4 parameters to the program (in order):
-
How many Philosophers are coming to dinner,
defaults to 5.
-
How long (in seconds) each Philosopher
eats, defaults to 6.
-
How many times each Philosopher eats, defaults to
4.
-
How long (in seconds) each Philosopher thinks,
defaults to 3.
These parameters are provided as command line parameters
and you will get ALL or NONE
but you must check for valid values.
Implementation Notes:
-
You are to use your C++ wrapper/class to handle the management of semaphores.
-
Note the word class is used here as an abstraction.
You do NOT have to create true C++ Classes.
Stuff You Need to Turn-in or Submit:
What to Turn-In:
-
A Commented, Partial Program Listing that Includes
-
An Intro program comment that describes your
overall implementation (1 to 2 pages):
-
your partner
-
including how long over all it took to write the algorithm;
to write the code; and to debug and to make work;
-
including the number of semaphores and
the use of each semaphore
-
a description of how you manage your processes,
e.g., something about how you manage your main program,
the Waiter, etc. Make sure to include comments about how
you terminate and determine termination of your processes.
-
Your comments need to be complete and detailed!!!
-
One or two Sample runs with the default input values.
There will be additional input values,
which will be used in demonstrating your program.
-
We do NOT want a copy of your full program listing!!!!!
What to Submit
submit<]b>
your full implementation, all the commented code of your
running implementation (yes, this is more than the hardcopy
that you turn-in).
Where to Turn-In Paper:
To the plastic bin outside mike's office.
References:
Notes:
-
If you decide to NOT implement shared memory with a dynamic size
array, then use a max size of 10 philosophers, but expect to
loose 4 points. You MUST also indicate this choice in the
documentation comments at the front of your program.
-
Handling Input:
If the input was correct, the program should output at the
beginning the correct input; the parameters are set to the inputs, and show
that. If there is no input or wrong numbers of input, then your program
should output this fact and say that the defaults are used and show what the
defaults are. If the values of the input are not valid, then your program
should state that and say that the defaults are used, and show what the
defaults are.
Last modified March 2, 03 by mike@cs.hmc.edu