Creating a guard area and changing its size

A program can create a memory object that consists of two areas: an area it can use immediately, called the usable area, and a second area, called a guard area. The system does not allow programs to use storage in the guard area.

To get a memory object with a guard area, use the IARV64 GETSTOR service with the SEGMENTS parameter to specify the size, in megabytes, of the memory object and the GUARDSIZE parameter to specify the size, in megabytes, of the guard area. Use GUARDLOC=LOW or GUARDLOC=HIGH to specify whether guard area is to be at the low end of the memory object or at the high end.

One reason for asking for a guard area is to reserve the area for future use. For example, a program can manage the parceling out of pages of the memory object. Another reason for using a guard area is so that the program requesting the memory object can protect itself from accidentally referencing storage beyond the end of the memory object, and possibly overlaying data in another adjacent memory object. For that, the program would use GUARDLOC=HIGH. If the program wanted to protect itself from another program that might be using an adjacent memory at a lower address, it would likely use GUARDLOC=LOW.

Use COND=YES, conditionally requesting the change, to avoid an abend if the request exceeds the MEMLIMIT established by the installation or if there are insufficient frames to back the additional usable area of the memory object. If it cannot grant a conditioned request, the system rejects the request, but the program continues to run.

The following illustration shows a memory object, three segments in size. GUARDLOC=HIGH creates the guard area at the highest addresses of the memory object. The memory object has two segments of usable storage and one segment on reserve for later use.
ieaa6u04

Use the IARV64 CHANGEGUARD service to increase or decrease the amount of usable space in a memory object by adjusting the size of the guard area. Your program cannot reference an address in the guard area; if it does, the program receives a program exception (0C4 abend). To avoid the abend, code a recovery routine to get control upon receiving the program exception; the recovery routine can retry and can then increase the usable part of the memory object (decreasing the guard area.)

The guard area does not count towards the MEMLIMIT set by the installation; the usable area does count toward the MEMLIMIT.