CS476/576

Assignment #4

Due Midnight, Wednesday Nov. 19, 2003


Write a C/UNIX program with the following descriptions:

NAME

domino - A  program that creates a set of tcp-connected processes.
SYNOPSIS
domino n [<host>]
DESCRIPTION

The program creates n > 1 processes. Process i creates process i+1, for i=1, 2, ...n-1.
Therefore,  process i is the
parent of process i+1 and  process i+1 is the child of process i, for i=1, 2,..., n-1.
Each process is connected to its next process with a tcp socket. 

If process i is killed then all the other n-1 processes will be terminated.
Therfore killing any process will have a domino effect on all other processes.

Program Output:

Upon the creation of process i, the program displays the message:

START i:
        MyID=<pid1@host>,
        MyParentID=<pid2@host>,
        MyChildID=<pid3@host>

where <pid1>, <pid2> and <pid3> are processes ids on the <host> where the process runs.

Upon the termination of process i, the program displays  one of the following two messages (depending on whether the parent or child exited before the process):

Exit i (becuase PARENT exit)
or
Exit i (becuase CHILD exit)

The program has  one optional argument*: <host>
The odd numbered processes (number 1, 3, 5, ..etc)  runs on the localhost (i.e., where the domino command started) while the even numbered processes (number 2, 4, 6, ...etc) runs on <host>.
In such case each process sends its output using UDP messages to a UDPserver running on the localhost for displaying the recieved messages from the n processes on the localhost stdout.

* For  CS476 students: You may not implement this option.



To get a feeling and gain more details about the specificationof this program, execute my own solution under:

/home/cs476/public_html/fall03/assignments/a4/wahab/domino

Examples:

> ./domino 3 &
StartingUDPServer:
LocalHost=cash.cs.odu.edu,
RemoteHost=localhost,
NumberOfProcesses=3
START 1:
MyID=5900@cash.cs.odu.edu,
MyParentID=5899@cash.cs.odu.edu,
MyChildID=5901@cash.cs.odu.edu

START 2:
MyID=5901@cash.cs.odu.edu,
MyParentID=5900@cash.cs.odu.edu,
MyChildID=5902@cash.cs.odu.edu

START 3:
MyID=5902@cash.cs.odu.edu,
MyParentID=5901@cash.cs.odu.edu,
MyChildID=none(last process)


> kill -9 5901
Exit 3: (Because PARENT exit)

Exit 1: (Because CHILD exit)

BY BY...domino

> ./domino 3 cuba &
StartingUDPServer:
LocalHost=cash.cs.odu.edu,
RemoteHost=cuba,
NumberOfProcesses=3
START 1:
MyID=5916@cash.cs.odu.edu,
MyParentID=5915@cash.cs.odu.edu,
MyChildID=11345@cuba

START 2:
MyID=11345@cuba.cs.odu.edu,
MyParentID=5916@cash.cs.odu.edu,
MyChildID=5922@cash.cs.odu.edu

START 3:
MyID=5922@cash.cs.odu.edu,
MyParentID=11345@cuba.cs.odu.edu,
MyChildID=none(last process)


> kill -9 5922
Exit 2: (Because CHILD exit)

Exit 1: (Because CHILD exit)

BY BY...domino