Single Remote Service Request With Reply

Files:

Written by:

Nicholas T. Karonis

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

DeKalb, IL

February 1997

Description:

This program contains the *minimum* amount of code required to send a message from one process to another and wait for a reply.

This program requires two command line arguments, two integers. It first creates a endpoint/startpoint pair and places the startpoint along with the two command line argument integers into a Nexus buffer and sends it to an awaiting process. It then waits for a reply from the other process. This waiting is implemented by creating a monitor and placing a flag and condition variable inside. The sending process enters the monitor, clears the flag, and waits on the monitor's condition variable.

Sending a message is called initiating a "remote service request" (rsr). An rsr invokes a specified function (called a handler routine, or simply handler) on the receiving process.

The receiving process extracts the startpoint (to be used as a reply startpoint) and both integers from the buffer and calculates their sum. It then places the sum into another Nexus buffer and initiates an rsr which invokes another handler on the original process.

That handler extracts the sum from the buffer. It then enters the monitor, places the sum in the monitor's data field, sets the flag, and signals the condition variable.

Once the condition variable is signaled and the flag has been set, the sum may be extracted from the monitor's data field and the original operands and sum are printed.

In this program we chose to place the address of the monitor variable in the endpoint rather than simply making the monitor variable a global variable. This choice was made somewhat arbitrarily. The main motivation was to illustrate how to set a user pointer in an endpoint. See the Ring example where we chose to make the monitor a global variable instead.

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 rsr_with_reply

To run this program:

rsr_with_reply 1 2 -nx -n 1

This will start the master and slave on your current machine. It will calculate 1+2.

Output:

1 + 2 = 3

Instructional Goals: