Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 49
Example With Debugging Options
When program execution is initiated by the appropriate RUND command, the Inspect
tool immediately gains control of the primary process and sends a prompt to the
primary process's home terminal. At this time, you can enter Inspect commands.
When the command is given to resume execution, the backup process is created and
started; the Inspect tool immediately gains control of the backup process and issues a
prompt at the home terminal specified for the backup process. You can then enter
Inspect commands to debug the backup process.
If the primary process should fail, the backup process becomes the new primary
process and creates a new backup process; the home terminal for the original primary
process becomes the home terminal for the new backup process, and you can
continue debugging.
Following are the program modifications.
Debugging Modifications to the Program Declarations
The following variables are added to the declarations portion of the program:
/*Variables for debugging option*/
short arg_num; /*Number of run-time arguments*/
char terminal_p[ZSYS_VAL_LEN_FILENAME]; /*Name of primary
terminal*/
char terminal_b[ZSYS_VAL_LEN_FILENAME]; /*Name of backup
terminal*/
The following #include line is added:
#include <cextdecs (PROCESS_GETINFOLIST_)> nolist
The PROCESS_GETINFOLIST_ procedure is called by the get_terminal_name
function described later in this section.
Debugging Modifications to the Main Function
Code is added to the main function to accept two terminal names as input parameters
and to save the terminal names. The new code is shown in boldface print.
/*The main function determines whether it is running as the
primary or backup process and takes appropriate
action.*/
int main (int argc, char *argv[])
{
/*Save terminal names, if provided*/
arg_num = argc;
if (arg_num >= 3)
{
strcpy (terminal_p, argv[1]);
strcpy (terminal_b, argv[2]);
}
if (is_backup_process ())
backup_processing ();
else
{