COP5615 Operating System Principles

Spring 2000

Pre-Programming Assignment

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





As the title suggests, this is not a project but a simple assignment to prepare you for the upcoming distributed programming projects. With this assignment we will learn how to start remote processes on Unix machines connected to a network. What we are going to do now will save us time and trouble when it comes to work on the actual projects through the rest of this semester. We will use the code developed in this assignment in all of the projects that will need distributed system development. Therefore it is important to get this done now to be able to focus on the actual projects later.

You are to develop two fairly simple Java programs. First one Start.java will start 3 remote processes on 3 different Unix machines. These remote processes will run the program Site.java. This second program will simply print out I am Site X to a file named logX and then terminate. The X here indicates the number of the site which will be provided by the program Start.java as a program parameter. The site numbers will be 0, 1 and 2. In addition to the two programs we will also provide a configuration file named config (with no extension). This is a plain text file and will include the information about sites. The first program (Start.java) will read this file to obtain the information about the sites it is supposed to start remotely. Here is what this file should look like:

# This is a comment line, can be anywhere and should be ignored by the program
#
# The following lines specify the remote processes and the hosts to run on
# HOST SITE_NUMBER
sun114-11 0
sun114-12 1
sun114-13 2

There should not be any empty lines in the file for convenience and comments (indicated by a # at the first column of a line) can be anywhere in the file and should be skipped by the program.

The hosts (machines) we can use are the public Unix machines in the CISE department.

Remote Processes

You will use the Unix utility rsh (or ssh) to start remote processes. It accepts the machine name as a parameter and commands to execute separated by semicolons.

To execute the rsh command from a Java program, you should use the exec() method of the Runtime class. Please refer to the Java documentation for details.

Here is an example of the command sequence that is supposed to be executed by the exec().

exec("rsh " + machine + " cd " + path +  "; java Site " + number + " > log" + number)

Here rsh is the command to start a process that will run on the machine giving by the program variable machine. Immediately after the machine name you need to specify the cd command to make the current working directory of the new remote process be the same with the starting program. Hence the output of the remote processes will all be directed to the same directory we originally start the system. The path is another program variable and specifies the full path name of the directory that we started the Start.java program. Your program should obtain the current directory (full path) from the system. Please check out the getProperty() method of the System class to obtain the current directory. Note that you should use this path as exactly returned by the Java method. You need not append anything to this string.
After putting a semicolon you should specify the name of the program to run on the remote machine which is Site. After the program name you specify the parameter to the program Site, which is number. This is the number of the site being started. Following > redirects the standard output of the program to the file named logX. The X here is again the number of the Site.

Please note that the two programs and the config file should be placed in the same directory and the log files will be created in this directory.

Submission

You should submit only  the two programs mentioned above. There will not be a report for this assignment.

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