[Shootout-list] Re: ring of processes

Bengt Kleberg bengt.kleberg@ericsson.com
Mon, 11 Oct 2004 12:57:52 +0200


greetings,

it seems as if the sys5 message passing ipc makes for a too complicated 
test. there is some support for a simpler ring of messages test.

so, this is the new suggestion for ''about this test'' for ringmsg:

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.

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-1) should all do the same thing. When the sink stops it 
should print ''done''. 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 messages, 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 
''done'' and terminate the test.

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

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