[Shootout-list] Re: ring of processes

Bengt Kleberg bengt.kleberg@ericsson.com
Mon, 01 Nov 2004 11:49:05 +0100


greetings,

i have updated the about-this-test for ringmsg. please let me know if i 
have forgotten to address a particular concern.


About this test

For this test, each program should be implemented to do the same thing.

This is a test of interprocess communication using message passing.

This test has been designed to allow the number of simultaneous 
processes to grow with N. The purpose of this is to see how the message 
passing timings, for a particular language, changes as the number of 
processes increase.

Each test program should spawn N execution contexts (processes, though 
languages with limited concurrency can use threads). N will be the first 
argument to the test program. The number of messages between these 
processes will be 128*N. This number (128) comes from a study of 
erlang. The cost of creating a process was compared to the cost of 
sending a message. At 128 messages to each process the time spent in 
process creation was less than 10% of the total run time (excluding 
start/stop). When your favorite language is added we will change 128 to 
something that matches the relative performance of process 
creation/message passing in the new language. To make it simple to 
change we have 128 as the second argument to the test program.

When the test program spawn N execution contexts one execution context 
should be the master/source. It will behave differently from the others. 
One will be the sink. It, too, will behave differently from the others. 
The others (N-2) should all do the same thing. When the sink stops it 
should print total number of messages received. This should normally be 
the only thing printed by the test. If at any time there is an error in 
the program, the test program must report this in its output. Since this 
is a failure the test may stop right there.

The algorithm for the first process (master/source) shall be as follows:

    1. The first process (source) will wait for a ''start'' message from 
the last process (sink).
    2. The first process will send (128*N)-1 messages to the second 
process in the ring. The contents does not really matter, but should not 
be ''stop''.
    3. As the last message, send a message with the contents ''stop'' to 
the second process in the ring.

The algorithm for the last processes (sink) shall be as follows:

    1. Send a ''start'' message to the first process (source).
    2. Recive messages until a ''stop'' message arrives. Then print the 
total number of messages received (should be 128*N) and terminate the test.

The algorithm for all the other processes shall be as follows:

    1. Recive messages from the process before the process itself.
    2. Send the message to the process after the process itself.