Ring

Files:

Written by:

John Bresnahan
Doug Sale

High-Performance Computing Laboratory
Department of Computer Science
Northern Illinois University
DeKalb, IL

February 1997

Description:

This program requires a single command line argument, a character string. It first configures itself and all the slave processes in a ring:

                             master
                             ^     \
                            /       v
                       slave n     slave 1
                        ^              \
                       /                v
                  slave n-1            slave 2
                   ^                      \
                    \                      v
                     .                   slave 3
                      .                   /
                       ^                 /
                        \               v 
                         +----------- slave 4


The master then places the command line arg character string into a Nexus buffer, sends it to the first slave, and waits for it to be passed around the ring to eventually end up where it started.

In this program we chose to make the monitor variable a global variable rather than placing its address in an endpoint. This choice was made somewhat arbitrarily. See the RsrWithReply example where we chose to place the address of the monitor in an endpoint instead.

Running this program requires at least one other process.

To make this program:

Edit Makefile and change NEXUS_DIR to the name of the directory where you installed Nexus. This will be the directory you specified with the --prefix= switch when configuring Nexus. It is the directory that gets populated when you 'make install' Nexus.

make ring

To run this program:

ring "hello, world" -nx -n 2

This will start the master and two slaves on your current machine.

This program uses nexus_printf() which sends everything to stdout, so executing the program in this manner will likely display all output (including slave output) to your screen.

It will send the message "hello, world" around the ring.

Output:

Master Sent Message: hello, world
olympus#1:c0:t0:p16425: Slave 1 Received Message: hello, world
olympus#2:c0:t0:p16422: Slave 2 Received Message: hello, world
Master Received Message: hello, world

(NOTE: output lines might appear in a different order)

Instructional Goals: