CS 3733 Operating Systems
Assignment 6: Control of the Network Intercom
Part I: Reorganization - Due April 24, 1998
- Reorganize your server application so that the parent forks
a separate child to handle each direction of communication. In a
loop the server should do:
- Listen for a connection request.
- Open the audio device.
- Fork child 1 to do the play_open_file.
- Fork child 2 to do the record_from_open_file.
- Close the communfd.
- Wait for the children to finish.
- Close the audio device.
- Reorganize your client so that the parent forks a separate
child to handle each direction of communication. The client should:
- Make a connection request.
- Open the audio device.
- Fork child 1 to do the play_open_file.
- Fork child 2 to do the record_from_open_file.
- Close the communfd.
- Wait for the children to finish.
- Close the audio device.
- Exit.
Part II: Graceful Shutdown and Resumption - Due April 24, 1998
- Make a new subdirectory and copy your working programs from Part I
into it.
- Add the global static variables
child1_ID
and
child2_ID
to the server.
Modify the server code so that when the parent forks each child
it stores the PIDs in these variables. (This is so that the signal
handler can access these variables.)
- Add code to the SIGUSR1 signal handler in the server so that
it will kill each child. (Use the kill system call with SIGTERM.)
- Modify the client code in a similar way.
- Send the SIGUSR1 signal (kill -USR1 pid)
to the client from the shell and see
if it quits.
- Send the SIGUSR1 signal (kill -USR1 pid) to the server from
the shell and see if it terminates the communication session and
resumes listening.
NOTE: This code has a race condition. It
should work most of the time, but once in the while you might have
to send two signals to get it to quit. For extra credit,
identify and fix the race condition.
Part III: Helpers - Due in class on April 29 - testing starting at 8 am
In this part of the assignment you will make it easier for someone
to contact your server.
- Make a new subdirectory and copy the code from Part II into it.
- Modify your server so that before it goes into the loop it
creates the file
myFilename.csaudio
in your public_html
directory. This file contains
two lines. The first line is the name of the machine that the
server is running on (use gethostname
). The second
line is the port number that the server is listening on.
- Modify your client so that before it no longer takes two
command line arguments. Instead it reads the hostname and
port number from standard input.
- Install your client as a helper function in your Netscape
on the Sun network by following these
directions.
NOTE
In order to get the helper to read the csaudio file, install
the helper with the line:
cat %s | /fullpath/client
in the Application: box
- Put a link to
http://ringer.cs.utsa.edu/yourname/myFilename.csaudio
on your
homepage.
- Start your server on one machine and run netscape on another.
When you click on the above link, your client should start up and
connect to your server.
- Test your program with other members of the class.
Revision Date: 4/23/98