Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 24
Sending Messages From the Primary to the Backup
Receiving system status messages in the backup process. The system messages
tell the backup process when the primary process or CPU has failed.
This subsection gives a brief overview of communication between the primary and
backup processes. The procedures of the Guardian interprocess communication
facility are described in detail in the Guardian Procedure Calls Reference Manual. The
use of those procedures for communicating between processes is described in
Section 6 of this manual, Communicating With Processes.
Your program can use the FILE_OPEN_, WRITE[X], and READ[X] procedures in the
following way:
1. The primary process calls FILE_OPEN_ to open the backup process.
2. The primary process calls WRITE[X] to send state information messages to the
backup process.
3. The backup process calls FILE_OPEN_ to open the $RECEIVE file.
4. The backup process calls READ[X] to read status and state information messages
from the $RECEIVE file. The $RECEIVE file contains the state information
messages sent by the primary process and execution status messages sent by the
system.
You can implement a protocol in which the backup process replies to the primary
process by using the WRITEREAD[X], READUPDATE[X], and REPLY[X] procedures.
As explained later in this section, you can also use nowait I/O to allow the primary
process to check that the backup process has not failed.
Sending Messages From the Primary to the Backup
To send a message to the backup process, the primary process follows these steps:
1. Opens the backup process
2. Creates the message in a buffer
3. Sends the message to the backup process and, optionally, waits for a reply
To open the backup process, the primary process calls the FILE_OPEN_ procedure.
For example:
{
...Get backup process name and name length...
error = FILE_OPEN_(process_name, /*backup process name*/
process_name_len, /*name length*/
&backup_filenum); /*backup process file*/
/*number returned*/
}
The FILE_OPEN_ procedure returns the file number of the backup process.
The time at which the open finishes depends on the way the backup process opens
$RECEIVE. See Section 6, Communicating With Processes, for details.