The RESERVE macro reserves a device for use by a particular system; it must be issued by each task needing to reserve a device shared with one or more systems. The RESERVE macro protects the caller from interference by other tasks in the system and locks out other systems. The reserve actually occurs when the first I/O is done to the device after the RESERVE macro is issued. When the reserving program no longer needs the reserved device, it should issue a DEQ macro to release the resource. For information about the synchronous reserve feature, see z/OS MVS Planning: Global Resource Serialization and z/OS MVS Initialization and Tuning Guide.
For information about how to obtain the UCB address for a device, see the section “Finding the UCB Address for the RESERVE Macro” in z/OS MVS Programming: Authorized Assembler Services Guide.
If global resource serialization is active, the hardware RESERVE can be suppressed leaving a SYSTEMS ENQ depending on the contents of the resource name lists. See z/OS MVS Planning: Global Resource Serialization for information on resource name lists.
A RESERVE used with the MASID and MTCB operands provides a special form of the RESERVE macro that allows a further conditional control of a resource. One task, called the “issuing task” can issue a RESERVE macro for a resource specifying the ASID and TCB of another task, called the “matching task”.
The RESERVE macro is also described in z/OS MVS Programming: Assembler Services Reference ABE-HSP, with the exception of the MASID, MTCB, and ECB parameters.
The requirements for the caller are:
Environmental factor | Requirement |
---|---|
Minimum authorization: | Problem state with any PSW key. For the MASID,
MTCB, and ECB parameters, one of the following:
|
Dispatchable unit mode: | Task |
Cross memory mode: | For LINKAGE=SVC: PASN=HASN=SASN For LINKAGE=SYSTEM: PASN=HASN=SASN or PASN¬=HASN¬=SASN |
AMODE: | 24- or 31- or 64-bit |
ASC mode: | Primary |
Interrupt status: | Enabled for I/O and external interrupts |
Locks: | No locks held |
Control parameters: | If the caller's AMODE is 24-bit, all parameters must reside below 16 megabytes. |
Before issuing the RESERVE macro with a UCB address, an authorized caller must serialize the UCB against dynamic I/O reconfiguration requests. The caller can accomplish this serialization by allocating or pinning the UCB. Such serialization ensures that a dynamic I/O reconfiguration request does not delete or reuse the UCB before the RESERVE macro uses the address.
If a task issues two RESERVE macros for the same device without an intervening DEQ macro, the task ends abnormally unless the second RESERVE specifies the keyword parameter RET or ECB. (If a restart occurs after the caller successfully issued the RESERVE macro for a resource, the system does not reserve the device again; the caller must reissue the RESERVE macro.) If a DEQ macro is not issued for a particular resource, the system releases the reserved resource when the task ends.
The system counts and limits the number of concurrent resource requests in an address space. If an unconditional RESERVE (a RESERVE macro with RET=NONE) causes the number of global resource serialization requests to exceed the limit, the caller is abnormally terminated with a system code of X'538'. For further information about limiting concurrent requests for resources, see in z/OS MVS Programming: Assembler Services Guide. For further information about limiting global resource serialization requests, see z/OS MVS Programming: Authorized Assembler Services Guide.
Before issuing the RESERVE macro, the caller does not have to place any information into any register unless using it in register notation for a particular parameter, or using it as a base register.
Some callers depend on register contents remaining the same before and after issuing a service. If the system changes the contents of registers on which the caller depends, the caller must save them before issuing the service, and restore them after the system returns control.
The standard form of the RESERVE macro is written as follows:
Syntax | Description |
---|---|
name | name: symbol. Begin name in column 1. |
␢ | One or more blanks must precede RESERVE. |
RESERVE | |
␢ | One or more blanks must follow RESERVE. |
qname addr | qname addr: A-type address, or register (2) - (12). |
,rname addr | rname addr: A-type address, or register (2) - (12). |
, | Default: E |
,E | |
,S | |
, | |
,rname length | rname length: symbol, decimal digit, or register (2) - (12). |
,SYSTEMS | |
) | |
,RET=TEST | |
,RET=USE | |
,RET=HAVE | |
,RET=NONE | |
,ECB=ecb addr | ecb addr: A-type address, or register (2) - (12). |
,UCB=ucb addr | ucb addr: A-type address, or register (2) - (12). |
,LOC=BELOW | Default: LOC=BELOW |
,LOC=ANY | |
,MASID=matching-asid addr | matching-asid addr: A-type address, or register (2) - (12). |
,MTCB=matching-tcb addr | matching-tcb addr: A-type address, or register (2) - (12). |
,RELATED=value | value: any valid macro keyword specification. |
,LINKAGE=SVC | DEFAULT: LINKAGE=SVC |
,LINKAGE=SYSTEM | |
The parameters are explained as follows:
In either case, you can specify 0, which means that the length of the rname must be contained in the first byte at the rname addr.
RET=NONE specifies an unconditional request for the resource named on the macro.
If the return code for one or more requested resources is 4 and the request is not nullified by a corresponding DEQ, the ECB is posted when all the requested resources (specifically, those that initially received a return code of 4) are assigned to the requesting task.
If the task specified by the MASID and MTCB parameters is not using the resource, global resource serialization gives control to the issuer of the RESERVE and returns a return code indicating whether the resource can be used. If the task specified by MASID and MTCB parameters is using the resource, global resource serialization records a request for the resource, suspends the issuing task until the resource is available, or optionally returns a return code indicating that an ECB will be posted when the resource can be used.
The MASID and MTCB parameters are specified with the RET=HAVE, RET=TEST, or ECB parameters to elicit additional return codes that provide information about the owner of the resource.
See the description of rname length for information about specifying rname length with MASID and MTCB.
For LINKAGE=SVC, the linkage is through an SVC instruction. This linkage is valid only when the caller is in primary mode and the primary, home, and secondary address spaces are the same.
See z/OS MVS System Codes for explanations and responses for these codes.
Return codes are provided by the system only if you specify RET=TEST, RET=USE, RET=HAVE, or ECB; for RET=NONE, return to the task indicates that control of the resource has been assigned to the task. If the return code for the resource named in the RESERVE macro is 0, register 15 contains 0. If the return code is not 0, register 15 contains the address of a 12-byte storage area containing the return code, as shown in Figure 1.
The return codes for the RESERVE macro with the RET=TEST parameter are described in Table 1.
Hexadecimal Return Code | Meaning and Action |
---|---|
0 | Meaning: The resource is immediately available. Action: None required. However, you might take some action based on your application. |
4 | Meaning: The resource is not immediately
available or There might be contention on the reservethe hardware
reserve is done synchronously. There might be contention on the reserve. Action: None required. However, you might take some action based on your application. |
8 | Meaning: A previous request for control
of the same resource has been made for the same task. The task has
control of the resource. Action: None required. However, you might take some action based on your application. To determine whether the task has exclusive control or shared control of the resource, check bit 3 of Byte 0 as shown in Figure 1. If bit 3 is off, the task has exclusive control; If bit 3 is on, the task has shared control. |
14 | Meaning: A previous request for control
of the same resource has been made for the same task. The task does
not have control of the resource. Action: None required. However, you might take some action based on your application. |
20 | Meaning: The matching task (the task specified
in the MASID and MTCB parameters) owns the resource. Action: None required. However, you might take some action based on your application. |
The return codes for the RESERVE macro with the RET=USE parameter are described in Table 2.
Hexadecimal Return Code | Meaning and Action |
---|---|
0 | Meaning: The active task now has control
of the resource. Action: None. |
4 | Meaning: The resource is not immediately
available. Action: None required. However, you might take some action based on your application. |
8 | Meaning: A previous request for control
of the same resource has been made for the same task. The task has
control of the resource. Action: None required. However, you might take some action based on your application. To determine whether the task has exclusive control or shared control of the resource, check bit 3 of Byte 0 as shown in Figure 1. If bit 3 is off, the task has exclusive control; If bit 3 is on, the task has shared control. |
14 | Meaning: A previous request for control
of the same resource has been made for the same task. The task does
not have control of the resource. Action: None required. However, you might take some action based on your application. |
18 | Meaning: Environmental error. The limit
for the number of concurrent resource requests has been reached.
The task does not have control of the resource unless some previous
ENQ or RESERVE request caused the task to obtain control of the resource. Action: Retry the request one or more times. If the problem persists, consult your system programmer, who might be able to tune the system so that the limit is no longer exceeded. |
The return codes for the RESERVE macro with the RET=HAVE parameter are described in Table 3.
Hexadecimal Return Code | Meaning and Action |
---|---|
0 | Meaning: The active task now has control
of the resource. Action: None. |
8 | Meaning: A previous request for control
of the same resource has been made for the same task. The task has
control of the resource. Action: None required. However, you might take some action based on your application. To determine whether the task has exclusive control or shared control of the resource, check bit 3 of Byte 0 as shown in Figure 1. If bit 3 is off, the task has exclusive control; If bit 3 is on, the task has shared control. |
14 | Meaning: A previous request for control
of the same resource has been made for the same task. The task does
not have control of the resource. Action: None required. However, you might take some action based on your application. |
18 | Meaning: Environmental error. The limit
for the number of concurrent resource requests has been reached.
The task does not have control of the resource unless some previous
ENQ or RESERVE request caused the task to obtain control of the resource. Action: Retry the request one or more times. If the problem persists, consult your system programmer, who might be able to tune the system so that the limit is no longer exceeded. |
20 | Meaning: The matching task (the task specified
in the MASID and MTCB parameters) owns the resource. Action: The caller can use the resource, but it must ensure that the owning task does not terminate while the caller is using the resource. If the caller requested exclusive control, then this return code indicates that the matching task is the only task that currently owns the resource. If the caller requested shared control and the owning task requested shared control, this return code might indicate that a previous task had requested exclusive control. The caller must issue a DEQ macro to cancel this RESERVE request. |
28 | Meaning: The caller cannot obtain exclusive
control of the resource using the RESERVE macro with the MASID and
MTCB parameters. The matching task's involvement with other tasks
precludes control by the caller. Action: This task must not issue a DEQ macro to cancel the RESERVE request. |
44 | Meaning: The caller is violating a restriction
of using the RESERVE macro with the MASID and MTCB parameters in one
or more of the following ways:
Action: Do not use the resource; the caller does not have control of it. |
The return codes for the RESERVE macro with the ECB parameter are described in Table 4.
Hexadecimal Return Code | Meaning and Action |
---|---|
0 | Meaning: The active task now has control
of the resource. Action: Do not wait on the ECB; it will not be posted. |
4 | Meaning: The ENQ resource is not immediately
available or the hardware reserve is done synchronously, so contention
might exist on the reserve. Action: None required. However, you might take actions based on your application. To measure the time you want to wait for resolving the contention, you can set a timer with ECB and wait on both the RESERVE ECB and the timer ECB. |
8 | Meaning: A previous request for control
of the same resource has been made for the same task. The task has
control of the resource. Action: Do not wait on the ECB; it will not be posted. To determine whether the task has exclusive control or shared control of the resource, check bit 3 of Byte 0 as shown in Figure 1. If bit 3 is off, the task has exclusive control; If bit 3 is on, the task has shared control. |
14 | Meaning: A previous request for control
of the same resource has been made for the same task. The task does
not have control of the resource. Action: Do not wait on the ECB; it will not be posted. |
18 | Meaning: Environmental error. The limit
for the number of concurrent resource requests has been reached.
The task does not have control of the resource unless some previous
ENQ or RESERVE request caused the task to obtain control of the resource. Action: Do not wait on the ECB; it will not be posted. Retry the request one or more times. If the problem persists, consult your system programmer, who might be able to tune the system so that the limit is no longer exceeded. |
20 | Meaning: The matching task (the task specified
in the MASID and MTCB parameters) owns the resource. Action: Do not wait on the ECB; it will not be posted. The caller can use the resource, but it must ensure that the owning task does not terminate while the caller is using the resource. If the caller requested exclusive control, then this return code indicates that the matching task is the only task that currently owns the resource. If the caller requested shared control and the owning task requested shared control, this return code might indicate that a previous task had requested exclusive control. The caller must issue a DEQ macro to cancel this RESERVE request. |
24 | Meaning: The caller that specifies the
RESERVE macro with the MASID and MTCB parameters will have exclusive
control after the ECB is posted. Action: Wait on the ECB. Once the ECB is posted, the caller may use the resource, but must ensure that the matching task does not terminate while the caller is using the resource. The caller must issue a DEQ macro to cancel the RESERVE request. |
28 | Meaning: The caller cannot obtain exclusive
control of the resource using the RESERVE macro with the MASID and
MTCB parameters. The matching task's involvement with other tasks
precludes control by the caller. Action: Do not wait on the ECB; it will not be posted. The caller must not issue a DEQ macro to cancel the RESERVE request. |
44 | Meaning: The caller is violating a restriction
of using the RESERVE macro with the MASID and MTCB parameters in one
or more of the following ways:
Action: Do not wait on the ECB; it will not be posted. Do not use the resource; the caller does not have control of it. |
RESERVE (MAJOR3,MINOR3,E,,SYSTEMS),UCB=(R3)