Develop a program package to simulate a toy distributed system by
using the TCP(UDP)/IP. Your program must be able to
run on several computers. On each machine, there are a set of concurrent
processes and a communication server process. The system
architecture is shown in Figure 1, where Processor 1, 2 and 3 are computers of
your system installed with a communication server. Each processor
hosts many concurrent processes such as ti's, si's and qi's(Note, a process can have an
arbitrary symbolic name).

Figure 1: System
Architecture
The concurrent processes use high level system primitives: register, terminate, send
and receive to communicate with the system and with each other.
where process_name and msg are character strings. Communication primitives adopt asynchronous protocol. For primitive receive, a special process_name “ANY” can be used to receive a message from any process. The return value of a receive-like primitive is either 1 or 0, the former indicates a successful execution and the later means that there is no available message or the sender does not exist.
For example, a process Romeo might
have the following code skeleton:
int
main(){
register(“Romeo”);
send(“Juliet”, “Date
tonight, Be there or be square”);
block_receive(“Juliet”, msg_buffer);
processing(msg_buffer);
terminate(“Remeo”);
}
System primitives talk to its local communication server directly.
The message format between a concurrent process and the communication server
is:
|
REQUEST |
|
SENDER |
|
RECEIVER |
|
MESSAGE |
where REQUEST can be one of Registration,
Termination, Send, Receive, Block_receive to indicate
the task to be performed.
A communication server is a midware (a perpetual process) to direct interprocess communications. The major functions are as following:
Based
on your system API, you must conduct at least three tests, such as:
Test 1: You should create several
concurrent processes running on at least three machines to simulate
an election algorithm.
The major function of each concurrent process should be:
You should show two sample runs: 3 concurrent processes on each machine and 10 concurrent processes on each machine.
Test 2: The second experiment consists of 12 processes, which are connected
into a (logic) ring network (at least three machines each holding 4
processes as the ring nodes). A token circulates alone the ring. Each process
randomly generates
a message and its destination. A process can send the
message only when the token is received and then attach the message
to the token.
Test
3: You should specify another test case by your imagination.