Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 37
Program Declarations
UPDATE_MESSAGE is an application-defined message that contains the current
state information. In this example, the value of the counter serves as both
application state and control state information: it is the data needed by the backup
process to continue processing (application state), and it defines the point at which
processing is to resume (control state). The primary process passes this value to
the backup process, which updates its state information.
IGNORE_MESSAGE is an application-defined message number that, for internal
processing, is substituted for the number of a message that has been received
from a source other than the primary process or the system. After a reply is sent
with an indication of OWNERSHIP_ERROR, no further action is taken on such a
message.
The message declaration portion of the program serves the following purposes:
Provides macros that define the message numbers. Note that the system
message numbers are negative and the application-defined message numbers are
positive.
Declares a structure for each of the three message formats. The first member of
the structure contains the message number, and the second member is a union
with one member per message format. The information contained in the system
messages is not used (only the message number is used), so the exact structure is
not defined.
Two other elements are defined that are used by the backup process if it receives a
message it does not expect: IGNORE_MESSAGE is used as a message number and
is placed in the message number portion of the message structure, and
OWNERSHIP_ERROR is an error value that is returned to the sender.
The message declarations are:
/*message numbers*/
#define CPU_DOWN -2 /*system message*/
#define PROCESS_DELETION -101 /*system message*/
#define UPDATE_MESSAGE 1 /*application message*/
#define IGNORE_MESSAGE 0 /*application message*/
#define OWNERSHIP_ERROR 200 /*used by backup*/
#define FEOWNERSHIP 200
#define IS_BACKUP 6 /* Returned from PROCESS_GETPAIRINFO_*/
#define RECEIVE_FILENAME "$RECEIVE"
/* Maximum file name length (plus 1 to allow for null
terminator)*/
#define MAXNAMELEN 36
/* Process handle size and null process handle. A phandle is 10
words long; a null phandle has all 10 words set to -1 */