Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 51
Example With Debugging Options
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);
}
Function get_terminal_name
Function get_terminal_name returns the home terminal name for the current
backup process. It is called by initialize_backup. The purpose of this function is
to enable you to debug multiple layers of primary process failure and backup takeover.
Each time a primary process fails, the backup process becomes the new primary
process and creates a new backup process. The home terminal for the new backup
process is the home terminal of the previous primary process. Thus, the home
terminals for the primary and backup processes are switched with each failure and
takeover.
Function get_terminal_name does the following:
1. Calls PROCESS_GETINFOLIST_ to retrieve the name of the home terminal
2. Tests to determine which name is the correct home terminal name
3. Places the appropriate name in the return parameter
Function get_terminal_name is as follows:
void get_terminal_name (char **name)
{
short result[40];
short ret_attr_list[2];
short result_length;
short error;
char fn[40];
ret_attr_list[0] = 5; /*Get home terminal name*/
error = PROCESS_GETINFOLIST_ (,,,,, ret_attr_list, 1,
result, 40, &result_length);
strncpy (fn, (char*) &result[1], result[0]);
fn[result[0]] = 0;
if (strcmp (fn, terminal_b))
*name = terminal_b;
else