COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

05 NEW-BASE PIC 9(4) VALUE 0.
77 BCPU PIC S9(2) COMP VALUE -1.
77 PARAM PIC X(9) VALUE SPACES.
77 PARAM-RET PIC X VALUE SPACES.
77 ERROR-CODE PIC S9(4) COMP VALUE 0.
PROCEDURE DIVISION.
CENTRAL SECTION. ...
OPEN I-O TEST-FILE SHARED SYNCDEPTH 1.
PERFORM GET-CPUNUM.
STARTBACKUP BCPU, 1.
IF PROGRAM-STATUS NOT = "0000"
DISPLAY "STARTBACKUP UNSUCCESSFUL, STATUS = ",
PROGRAM-STATUS.
STOP RUN.
PERFORM UPDATE-RECS
UNTIL UPDATES-DONE.
...
GET-CPUNUM.
MOVE "BACKUPCPU" TO PARAM.
ENTER "SMU_Param_GetText_" USING PARAM PARAM-RET
GIVING ERROR-CODE.
MOVE PARAM-RET TO BCPU.
IF BCPU < 0 OR BCPU > 15
DISPLAY "BACKUP CPU INVALID, RUNNING WITHOUT BACKUP". UPDATE-RECS.
...
READ TEST-FILE WITH LOCK.
...
CHECKPOINT TEST-FILE,
TEST-REC,
CKPT-DATA.
IF PROGRAM-STATUS > "0000"
AND PROGRAM-STATUS < "1000"
DISPLAY "Backup took over".
REWRITE TEST-REC WITH UNLOCK.
...
After the program is compiled and debugged, it must be run as a named process (see Process
Names (page 920)).
Designing Programs for the Fault-Tolerant Facility
You must design a program to use the fault-tolerant facility. It is very difficult, if not impossible, to
retrofit the use of the fault-tolerant facility to an existing program.
A checkpoint is a location in the program at which processing resumes when a takeover occurs.
All data from the primary process that is part of the program state must be checkpointed to the
backup process if the takeover is to succeed.
You must checkpoint before any nonretryable operation, such as a write to disk. You can (for
operator convenience) checkpoint after a read from a terminal. You can (for programming
convenience) checkpoint after a read from tape.
If your SYNCDEPTH exceeds one, and you open or close a file during checkpoint-protected
operation, you must checkpoint the sync blocks and record areas of all other files before the next
nonretryable operation.
952 Fault-Tolerant Processes