Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 40
Creating and Starting the Backup Process
communication so that the primary process can send messages to the backup
process. The operating system is allowed to select the CPU in which the backup
process will run. It is convenient to code these activities as separate functions, as
follows:
Function initialize_backup, which opens and starts the backup process;
called by function primary_processing.
Function primary_cpu, which returns the CPU number of the primary process
CPU. The CPU number is required by the MONITORCPUS procedure.
Function initialize_backup
Function initialize_backup performs the initialization tasks of the primary
process: it starts and opens a backup process so that the primary process can send
messages to the backup process.
To start the backup process, initialize_backup calls the C function
__ns_start_backup with the input parameter -1, which specifies that the operating
system is to select the backup CPU. __ns_start_backup returns the backup
process handle. initialize_backup then calls FILE_OPEN_ to open the backup
process.
/* This function is called by the primary process to
initialize the backup process. It starts the backup
process and opens it for interprocess communication */
void initialize_backup (void)
{
char process_name [MAXNAMELEN];
short process_name_len;
short error;
short error_detail;
/*Start the backup process*/
error = __ns_start_backup (&error_detail, (short) -1,
backup_phandle);
/*Get the process name of the backup process*/
error = PROCESSHANDLE_DECOMPOSE_ (backup_phandle,
/*cpu*/,
/*pin*/,
/*nodenumber*/,
/*nodename:nmax*/,,
/*nlen*/,
process_name,
MAXNAMELEN,
&process_name_len);
/*Open backup process for interprocess communication*/
error = FILE_OPEN_ (process_name, process_name_len,
&backup_filenum);
}