There are several methods of explicitly requesting virtual storage using the GETMAIN macro. Each method, which you select by coding a parameter, has certain advantages.
You can specify the location, above or below 16 megabytes, of the virtual area allocated by using the LOC parameter. (LOC is valid only with the RU, RC, VRU, and VRC parameters.)
To request virtual storage that can be above 16 megabytes, use LOC=31. To request virtual storage below 16 megabytes, use LOC=24.
If you code LOC=31 and indicate a subpool that is supported above 16 megabytes, GETMAIN tries to allocate the virtual storage area above 16 megabytes. If it cannot, and if the subpool is supported below 16 megabytes, GETMAIN allocates the area from virtual storage below 16 megabytes.
The element, variable, and list type of methods do not produce reenterable coding unless coded in the list and execute forms. (See Implicit requests for virtual storage for additional information.) When you use the last three types, you can allocate storage below 16 megabytes only.
The LOC parameter also allows you to indicate whether the real frames that back the virtual storage are below 16 megabytes, below 2 gigabytes, or anywhere.
To request virtual storage at a specific address, use LOC with the EXPLICIT parameter and specify the address desired on the INADDR parameter. When you specify EXPLICIT on a request for storage from the same virtual page as previously requested storage, you must request it in the same key, subpool, and central storage areas as on the previous storage request. For example, if you request virtual storage backed with central storage below 16 megabytes, any subsequent requests for storage in that virtual page must be specified as LOC=(EXPLICIT,24).
For more information, see the description of the GETMAIN macro in z/OS MVS Programming: Assembler Services Reference ABE-HSP.
In combination with these methods of requesting virtual storage, you can designate the request as conditional or unconditional. If the request is unconditional and sufficient virtual storage is not available to fill the request, the active task is abnormally terminated. If the request is conditional, however, and insufficient virtual storage is available, a return code of 4 is provided in register 15; a return code of 0 is provided if the request was satisfied.
.
.
GETMAIN EC,LV=16000,A=ANSWADD Conditional request for 16,000
bytes in central storage
LTR 15,15 Test return code
BZ PROCEED1 If 16,000 bytes allocated, proceed
DELETE EP=REENTMOD If not, delete module and try
GETMAIN VU,LA=SIZES,A=ANSWADD to get less virtual storage
L 4,ANSWADD+4 Load and test allocated length
CH 4,MIN If 8,000 or more, use procedure 1
BNL PROCEED1 If less than 8,000 use procedure 2
PROCEED2 ...
PROCEED1 ...
MIN DC H'8000' Min. size for procedure 1
SIZES DC F'4000' Min. size for procedure 2
DC F'16000' Size of area for maximum efficiency
ANSWADD DC F'0' Address of allocated area
DC F'0' Size of allocated area
The code shown in Figure 1 makes a conditional request for a single element of storage with a length of 16,000 bytes. The return code in register 15 is tested to determine if the storage is available; if the return code is 0 (the 16,000 bytes were allocated), control is passed to the processing routine. If sufficient storage is not available, an attempt to obtain more virtual storage is made by issuing a DELETE macro to free the area occupied by the load module REENTMOD. A second GETMAIN macro is issued, this time an unconditional request for an area between 4,000 and 16,000 bytes in length. If the minimum size is not available, the task is abnormally terminated. If at least 4,000 bytes are available, the task can continue. The size of the area actually allocated is determined, and one of the two procedures (efficient or inefficient) is given control.