[Shootout-list] ring of processes

Einar Karttunen ekarttun@cs.helsinki.fi
Mon, 4 Oct 2004 22:14:55 +0300


On 04.10 07:01, Brent Fulgham wrote:
> What about sending randomly within the ring?  These would be like 
> 'spokes' on the
> ring -- a send from P1 to P100 and P5 to P72, for example.

Here is an idea for a better message ring:

* Create N threads
* Create a permutation of [1..N] (stdin/prng)
* loop L times: sendMsg(the_permutation, myid); receive; 

send ([]        , prev) = sendMsgTo prev []
send ((next:lst), prev) = do sendMsgTo (next,myid)
                             ret <- receive
                             sendMsg prev ret


- Einar Karttunen