Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 44
Primary and Backup Processing
Function backup_processing
Function backup_processing handles the backup processing tasks, which include:
Open $RECEIVE so that the backup process can receive messages from the
primary process and the operating system.
Call MONITORCPUS to indicate to the operating system that the backup process
is to be notified if the primary process CPU fails.
Enter an infinite loop that reads and processes messages from $RECEIVE.
The three message types are processed as follows:
CPU_DOWN and PROCESS_DELETION indicate that the primary process has
failed. The backup process takes over execution and becomes the primary
process, then does the following:
Initializes a new backup process (by means of initialize_backup).
Sets the counter value to the most recent state information.
Calls primary_processing to continue as the primary process.
UPDATE_MESSAGE contains the counter value (the control state and application
state information). The backup process saves the counter value in the
counter_state variable.
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
process replies with ZFIL_ERR_OWNERSHIP. This triggers a process-handle refresh
in the sender, which can then retry sending the message.
Function backup_processing is as follows:
/*This function performs processing for the backup process.
It opens $RECEIVE, monitors the primary processor, and
executes a loop that receives messages through $RECEIVE.*/
void backup_processing (void)
{
short receive_filenum;
message_format message;
short countread;
zsys_ddl_receiveinformation_def receiveinfo;
short primary_value = 1;
short counter;
_cc_status cond_code;
short error;
short primary_phandle [PHANDLESIZE];
short null_phandle [PHANDLESIZE] = NULLPHANDLE;