Invoking the Checkpoint

The task invokes a checkpoint by executing a CHECKPOINT statement or by invoking the exported MCP procedure CALLCHECKPOINT. These methods are discussed separately in the following pages.

Using a CHECKPOINT Statement

ALGOL provides a CHECKPOINT statement. You can create multiple checkpoints by including a CHECKPOINT statement at several points in the program. Later, you can restart the task from any of these checkpoints.

Each CHECKPOINT statement can specify the following options:

  • Device option

    Determines the family where the checkpoint-related files are to be created. A value of DISK causes checkpoint files to be created on the family named DISK. A value of DISKPACK causes checkpoint files to be created on the family named PACK. You can specify PACK as a synonym for DISKPACK.

  • Disposition option

    Determines whether checkpoint files are saved. If the value is PURGE, then the checkpoint files are removed if the task terminates normally. If the value is LOCK, then checkpoint files are saved indefinitely. Later, you can use the checkpoint files to restart the task even if it terminated normally.

    The disposition option also determines if a checkpoint removes any previous checkpoint files created by the same task. If the disposition is PURGE, then any previous checkpoints that were invoked with a disposition of PURGE are removed. If the disposition is LOCK, then no previous checkpoints are removed.

    The following is an example:

CHECKPOINT (DISK,PURGE);

Using the CALLCHECKPOINT Procedure

A program can invoke a checkpoint by calling the MCP exported procedure CALLCHECKPOINT. You can create multiple checkpoints by invoking CALLCHECKPOINT at several points in the program. Later, you can restart the task from any of these checkpoints.

CALLCHECKPOINT is an integer procedure that receives four integer parameters, in the following order: UTYP, CPTYP, CCODE, CPNUM, and RSFLAG. The following table explains these parameters.

Parameter Name

Type

Input/ Output

Meaning

UTYP

Integer

Input

Similar to the device option in a CHECKPOINT statement. This parameter determines the family where the checkpoint-related files are created. Checkpoint files with a value of 1 are created on the family named DISK; files with a value of 17 are created on the family named PACK. These values can also be represented by the VALUE function in ALGOL as VALUE(DISK) and VALUE(PACK).

CPTYP

Integer

Input

Similar to the disposition option in a CHECKPOINT statement. This parameter determines whether checkpoint files are saved. A value of 0 is the same as a disposition of PURGE: checkpoint files are removed if the task terminates normally. A value of 1 is the same as a disposition of LOCK: checkpoint files are always saved indefinitely. Later, you can use the checkpoint files to restart the task even if it terminated normally.

     

The CPTYP parameter also determines if a checkpoint removes previous checkpoint files created by the same task. If the disposition is 0 (PURGE), any previous checkpoints invoked are removed. If the disposition is 1 (LOCK), no previous checkpoints are removed.

CCODE

Integer

Output

If the checkpoint is unsuccessful, the CCODE parameter stores one of the values listed in Checkpoint Completion Codes.

CPNUM

Integer

Output

CPNUM returns the number the system assigned to this checkpoint. The numbering scheme is explained in Creating Output Disk Files with a Checkpoint in this section.

RSFLAG

Integer

Output

If the task is restarted from a checkpoint, RSFLAG returns a value of 1 the next time the task invokes CALLCHECKPOINT. In this case, CALLCHECKPOINT actually does not invoke a checkpoint for the task. If the task invokes CALLCHECKPOINT a second time, RSFLAG returns a value of 0 and the checkpoint is actually invoked.

Procedure result

Integer

Output

A value of 0 indicates a successful checkpoint. A value of 1 indicates the checkpoint was not taken, in which case either the CCODE parameter or the RSFLAG parameter should be nonzero.

The following are ALGOL statements that declare the CALLCHECKPOINT procedure and invoke it:

LIBRARY MCPSUPPORT(LIBACCESS=BYFUNCTION,FUNCTIONNAME=“MCPSUPPORT.”);

INTEGER PROCEDURE CALLCHECKPOINT(UTYP, CPTYP, CCODE, CPNUM, RSFLAG);
  INTEGER UTYP, CPTYP, CCODE, CPNUM, RSFLAG;
  LIBRARY MCPSUPPORT;

INTEGER CCODE_ACTUAL, CPNUM_ACTUAL, RSFLAG_ACTUAL, CPRESULT;

CPRESULT:= CALLCHECKPOINT(VALUE(DISK),1, CCODE_ACTUAL, CPNUM_ACTUAL,
  RSFLAG_ACTUAL);

The following COBOL85 program uses the explicit library interface to invoke the CALLCHECKPOINT procedure. The invocation specifies a device option of PACK and a disposition of PURGE.

IDENTIFICATION DIVISION.
PROGRAM-ID. CHECK-POINT.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
        SELECT ATTR-FILE ASSIGN TO DISK.
DATA DIVISION.
FILE SECTION.
FD ATTR-FILE.
01 ATTR-REC PIC X(80).
WORKING-STORAGE SECTION.
77 CHECKPOINTDEVICE PIC S9(11) USAGE BINARY.
77 CHECKPOINTTYPE   PIC S9(11) USAGE BINARY.
77 COMPLETIONCODE   PIC S9(11) USAGE BINARY.
77 CHECKPOINTNUMBER PIC S9(11) USAGE BINARY.
77 RESTARTFLAG      PIC S9(11) USAGE BINARY.
77 RSLT             PIC S9(11) USAGE BINARY.
77 VALUE-OF-PACK    PIC S9(11) USAGE BINARY.
77 VALUE-OF-PURGE   PIC S9(11) USAGE BINARY VALUE 0.
LOCAL-STORAGE SECTION.
LD LD-CALLCHECKPOINT.
77 CHECKPOINTDEVICE PIC S9(11) USAGE BINARY.
77 CHECKPOINTTYPE   PIC S9(11) USAGE BINARY.
77 COMPLETIONCODE   PIC S9(11) USAGE BINARY.
77 CHECKPOINTNUMBER PIC S9(11) USAGE BINARY.
77 RESTARTFLAG      PIC S9(11) USAGE BINARY.
77 RSLT             PIC S9(11) USAGE BINARY.
PROGRAM-LIBRARY SECTION.
LB MCPSUPPORT IMPORT
   ATTRIBUTE
   FUNCTIONNAME IS “MCPSUPPORT”
   LIBACCESS    IS BYFUNCTION.
ENTRY PROCEDURE CALLCHECKPOINT
   WITH   LD-CALLCHECKPOINT
   USING
          CHECKPOINTDEVICE
          CHECKPOINTTYPE
          COMPLETIONCODE
          CHECKPOINTNUMBER
          RESTARTFLAG
   GIVING
          RSLT.
PROCEDURE DIVISION.
INIT-PARA.
        CHANGE ATTRIBUTE KIND         OF ATTR-FILE
                                      TO PACK.
        MOVE   ATTRIBUTE KIND         OF ATTR-FILE
                                      TO VALUE-OF-PACK.
        PERFORM CHECKPOINT-PARA.
        STOP RUN.
CHECKPOINT-PARA.
        MOVE VALUE-OF-PACK  TO CHECKPOINTDEVICE.
        MOVE VALUE-OF-PURGE TO CHECKPOINTTYPE.
        CALL CALLCHECKPOINT
        USING
               CHECKPOINTDEVICE
               CHECKPOINTTYPE
               COMPLETIONCODE
               CHECKPOINTNUMBER
               RESTARTFLAG
        GIVING
               RSLT.