Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 61
Primary and Backup Processing
The four message types received by the backup process are processed as follows:
PROCESSOR DOWN and PROCESS DELETION indicate that the primary
process has failed. The backup process takes over execution as described earlier.
UPDATE_OPEN contains the file open state information for the input and output
files. This information is used by __ns_backup_fopen to backup open the files.
UPDATE_MESSAGE contains the file state information for the input and output
files. This information is used by __ns_fset_file_state to update the file
state.
Statements are included to test the process handle of the sender of the incoming
message and to return an appropriate response if the sender is not the primary
process or the system. If the message is from an unexpected sender, the backup
replies with OWNERSHIP_ERROR. This triggers a process-handle refresh in the
sender, which can then retry sending the message.
The program statements are as follows:
/*This function performs the backup processing: it opens
$RECEIVE, monitors the primary processor, and reads and
processes messages from $RECEIVE.*/
void backup_processing (void)
{
short receive_filenum;
message_format message;
short countread;
receive_info_type receive_info;
short primary_value = 1;
short cond_code;
short error;
/*Open $RECEIVE*/
error = FILE_OPEN_ (RECEIVE_FILENAME,
(short) strlen (RECEIVE_FILENAME),
&receive_filenum,
/* access */,
/* exclusion */,
/* nowait */,
/* receive depth */1);