Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 26
Monitoring the Backup Process
switch (msg_buffer.number)
{
case ... /*Processor failure*/
case ... /*Process deletion*/
...Backup takes over for primary...
case ... /*State information*/
...Update control state ...
... Update application state ...
... Update file state ...
}
Monitoring the Backup Process
When writing an active backup application, it is advisable to structure the primary
process to periodically check the backup process to ensure that it is running and ready
to take over in the event of a primary process failure. Some ways of monitoring the
backup process are discussed below.
Calling PROCESS_GETPAIRINFO_
You can monitor the backup process by calling the PROCESS_GETPAIRINFO_
procedure. This procedure returns the process handle of the backup process; if the
backup process does not exist (has terminated due to process or CPU failure, the
process handle has a null value). The examples at the end of this section show a
user-written C function that calls PROCESS_GETPAIRINFO_ to monitor the backup
process.
Using Nowait I/O
An alternative method for detecting a failed backup process or CPU is to use NOWAIT
I/O as follows:
Open the backup process for nowait I/O (by specifying the appropriate parameter
in the FILE_OPEN_ call).
When performing write operations to the backup process (for updating state
information), call AWAITIO[X] with a positive value for the timelimit parameter.
If the write to the backup process does not finish within the specified time limit, the
primary process can perform further checking to determine whether the backup
has actually failed.
Checking I/O Error Status
You can monitor the backup process simply by checking the error status code after an
I/O operation that sends state information to the backup process. If the backup
process no longer exists, an error condition is returned.