Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 8
Organizing an Active Backup Program
Organizing an Active Backup Program
This subsection expands on the overview presented at the beginning of this section to
explain how to put together an active backup program. Figure 27-1 shows a general
structure for an active backup program.
When an active backup program begins execution, it must first determine whether it is
executing as the primary process or the backup process by calling
PROCESS_GETPAIRINFO_.
The code for the primary process of a process pair consists of two phases: an
initialization phase and an application processing phase. During the initialization
phase, the primary process performs the tasks associated with creating and starting
the backup process. During the application phase, the primary process executes the
application and sends current state information to the backup process.
The code for the backup process consists of a message-processing loop, followed by
an initialization phase and application processing phase. The initialization and
Figure 27-1. Active Backup Program Structure
VST132.VSD
Initialization Phase
OPEN Files
Get file open state info
Create backup process
Send file open stats to
backup
Main Processing Loop
READ entry from terminal
READ record from disk
Update record in memory
Send state info to backup
WRITE updated record to
disk
Message-Processing Loop
READ $RECEIVE
Y
Primary failure?
N
Update memory with
current state
Take over Execution
Create new backup
Continue application
processing
READ...
READ...
Update...
Send
WRITE...
Is current process the primary or the backup?
Primary Process Backup Process