Open System Services Programmer's Guide
Using the $RECEIVE File
OSS and Guardian processes can use Guardian procedures to communicate between nodes,
between processors, and within the same processor through $RECEIVE. $RECEIVE is a special file
in the Guardian filesystem through which a process can receive system messages or messages
from other processes.
The basic algorithm requires a server process to open its $RECEIVE file and accept messages from
one or more requester processes that open the server process file (in UNIX terms, each requester
opens the server process as a special file in the Guardian file system). The server replies to received
messages as necessary and requester processes see the replies as coming from the server process
file. The use of $RECEIVE is described in the Guardian Programmer’s Guide.
Example 46 (page 192) and Example 47 (page 194) should give you an idea of how the $RECEIVE
interprocess communication mechanism works and provide you with a template you can expand
in your applications. The Guardian Programmer’s Guide contains detailed instructions and examples
on using $RECEIVE, and you should read it before expanding these examples.
The server program in Example 46 is compiled as a linked program file named server1 that is
secured for execution in the current working directory. The requester program in Example 47 is
compiled as a linked program file named requester1 that is secured for execution in the current
working directory.
The server process can be started in the background from the OSS shell using the command
run -name=/G/echo ./server1 &
which /G/echo gives the running server process the process name $ECHO in the Guardian file
system. That process name is used by requesters to open the server program.
After you start the server process, the requester process in Example 47 can be started in the
foreground from the OSS shell using the command:
.\requester1
Alternatively, both processes can be started in the foreground from separate terminal sessions. The
following sample dialog illustrates the processes run from two terminal sessions. The server terminal
session for the program in Example 46 appears as:
/home/software/chrisbl/cabpubs: run -name=/G/echo ./server1
Server starting
Message received = hello
Message received = goodbye
Server stopping
/home/software/chrisbl/cabpubs:
while the requester terminal session for the program in Example 47 appears as:
/home/software/chrisbl/cabpubs: ./requester1
Requester starting
?hello
Read 6 bytes back from server
?goodbye
Read 8 bytes back from server
?
/home/software/chrisbl/cabpubs:
Interprocess-Communication Interoperability 191