COP5615 Operating System Principles

Spring 2001

Project 2

Date Assigned: February 22nd,
Date Due: March 13th, 11:59pm
(FEEDS Date Due: March 15th, 11:59pm)








In this project we will implement a distributed client/server version of the solution to the Dining Philosophers problem. The soution will be based on the one we have already implemented for Project 1.

This time, the philosophers do not like to sit around a table but prefer to work in their offices (remote sites). After building up an appetite, they call the chief waiter of the restaurant (main server thread on the local host) by sending a message. Upon receiving this message, chief waiter assigns the job (grabbing the forks) to a waiter (create a thread). Then chief waiter goes back to listen to other requests from the philopsophers. The waiter reaches the table and try to grab the forks for the requesting philosopher. Even the philosophers do not sit at the table, their positions are preserved by the waiters and they can only use their left and right forks as the original problem suggests. Immediately after grabbing the forks, the waiter gives the forks (sends a message) to the requesting philosophers. Since the waiter is done with serving, he can now leave the restaurant (the thread finishes its execution and exits). When the philosopher is done with eating, he calls the chief waiter again (send a message) and the chief waiter assigns another waiter (server thread) to put down the forks on the table at their respective places, then the waiter thanks to the philospher (sends a confirmation message back to the philosopher) and leaves (the thread exits).

As the scenario above suggests, our distributed system will consist of a server that implements the table, forks and necessary synchronization and several clients (philosophers) running on remote machines and communicate with the server using TCP/IP protocol suite. Hence philosophers will not only be seperate processes but also distributed processes running on the remote hosts (machines).

In addition to the multithreading and synchronization, we will also need an application programming interface (API) to use TCP/IP protocols which will allow us to communicate with remote machines through a network (in our case CISE network). For this purpose we will be using the socket API provided by Java.

Specifically, we will be using User Datagram Protocol (UDP) hence Datagram sockets as the API to the protocol in Java. Please see Java documentation for details of DatagramSocket class.

The name of the program to start the system will be Start.java. This program will read the configuration file config, start the server on the local machine and then start the clients on remote machines. Reading the config file and starting the remote processes will be done the same way as the pre-programming assignment. Note that directory for all the files for both local and remote processing will be the same current directory of the user.

You do not need to reimplement the solution to the Dining Philosophers problem. Your implementation from Project 1 should work. Therefore it is recommended to reuse code as much as possible from both Project 1 and pre-programming assignment.
 

Format of the configuration file config

# First line is the port number, on which the server is listening
3000
#Second line is the number of eating phases for all the philosophers (clients)
5
# Remaining lines specify the host name where the PHILOSOPHERs (clients) reside
# Phil. A
sun114-11
# Phil. B
sun114-12
# Phil. C
sun114-13
# Phil. D
sun114-22
# Phil. E
sun114-33
 

Output Formats

The output generated by the server on screen should look like the following:

A        B        C        D        E
=====================================
         TF
         FS
TF
                  TF
         PF
         CS
FS
                  FS
                           TF
                                    TF
         TF
PF
CS
                                    FS
                  PF
                  CS
         FS
                  TF
                                    PF
                                    CS
                           FS
                                    TF
         PF
         CS
                           PF
                           CS
                  FS
                                    FS
TF
                           TF
         TF
                  PF
                  CS
         FS
                                    PF
                                    CS
:::
:::
======================================
TF: philosopher is attempting to Take the Forks (request received from phil.)
PF: philosopher is attempting to Put down the Forks (request received from phil.)
FS: Forks were Sent to the philosopher (similar to Eating in project1)
CS: Confirmation (of PF) were sent to the philosopher (similar to Thinking in project1)

A client should print out its actions like the following:

I am Philosopher A

I am EATING
I am THINKING
I am EATING
I am THINKING
I am EATING
I am THINKING
I am EATING
I am THINKING
I am EATING
I am THINKING
======================================

Requirements

Note on Runaway processes

Your threads should terminate gracefully. While testing your programs runaway processes might exist. However these should be killed frequently. Since the department has a policy on this matter, your access to the department machines might be restricted if you do not clean these processes.

To clean all Java processes easily in Unix, type

skill java

To check whether there are runaway processes on remote hosts, type

rsh <host-name> ps -u <your-username>

and to clean

rsh <host name> skill java
 

Submission

Please refer to the project general requirements page for submission procedure and use proj2 for the -p argument of turnin if you are a local student and FEEDSproj2 if you are a FEEDS student.