[Shootout-list] Re: ring of processes
Raymond Racine
rracine@adelphia.net
Mon, 11 Oct 2004 20:22:53 -0400
On Mon, 2004-10-11 at 06:57, Bengt Kleberg wrote:
> 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.
Could we clarify "send". Let the process sending a message be the
"sender", the process next in the chain the "receiver".
Possibilities.
--------------------------------------------------------------------
Synchronous
send (ch, msg)
sends the message msg on the synchronous channel ch. This
operation blocks the calling process until there is another
process attempting to receive a message from the channel ch, at
which point the receiving process gets the message and both
processes continue execution.
recv ch
receives a message from the channel ch. This operation blocks
the calling process until there is another process attempting to
send a message on the channel ch, at which point both processes
continue execution.
----------------------------------------------------------------------
Asynchronous
send (mb, msg)
sends the message to the receiving process's "mailbox". The
sending process shall always be able to immediately send even if
the receiving process is busy processing. Note: the send msg
operation is a non-blocking operation.
recv mb
receive the next message from the receiving processes incoming
"mailbox". If, the receiving mailbox is empty, then the process
waits until there is a message available.
Other possibilities exist as well.
Ray