Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 62
Primary and Backup Processing
/*Monitor the primary process processor. The backup process
receives a message if the primary process processor fails*/
MONITORCPUS ((unsigned short)(0x8000 >> primary_cpu ()));
/*Infinite loop that receives and processes messages*/
for (;;)
{
/*Read the next message from $RECEIVE with the intention
of replying*/
cond_code = READUPDATEX (receive_filenum,
(char *) &message,
(short) sizeof (message_format),
&countread);
/*Check process handle of sender of incoming message*/
FILE_GETRECEIVEINFO_ ((short *) &receive_info);
if (PROCESSHANDLE_COMPARE_ (primary_phandle,
(short *) &receive_info.sender_phandle) != 2
&& memcmp (&receive_info.sender_phandle,
null_phandle, PHANDLESIZE*2) != 0)
{ /*Message is not from primary process or system*/
REPLYX ( , , , , OWNERSHIP_ERROR);
message.msgnumber = IGNORE_MESSAGE; }
else
REPLYX ( , , , , 0);
/*process based on message number*/
switch (message.msgnumber )
{
case CPU_DOWN:
case PROCESS_DELETION:
/*Backup takes over*/
/*Start replacement backup process*/
initialize_backup ();
/*Continue the work of the application*/
primary_processing ();
break;