The ENQUEUE statement acquires or tests the availability of a resource or list of resources. Resources are defined during installation and system generation and typically include storage areas, common routines, queues, and processor time.
An enqueued resource can be exclusive or shared:
Note: An exclusive ENQUEUE request prohibits another task from enqueuing a resource by name; however, it does not prohibit the use of the resource by another task. Therefore, to effect true resource protection, you must enqueue and dequeue resources consistently.
►►─── ENQUEUE ─┬──────────┬───────────────────────────────────────────────────► ├─ WAIT ◄ ─┤ ├─ NOWAIT ─┤ └─ TEST ───┘ ┌─────────────────────────────────────────────────────────────────────┐ ►─▼─ NAME (resource-id) LENGTH (resource-id-length) ──┬───────────────┬─┴ ; ─►◄ ├─ EXCLUSIVE ◄ ─┤ └─ SHARED ──────┘
Specifies that the system is to wait for all resources to be freed if it cannot service the request immediately. WAIT is the default.
Specifies that the system is not to wait to acquire resources that are not currently available. If NOWAIT is specified, the program should check the ERROR_STATUS field in the IDMS DC communications block to determine if the function has been completed. If the ERROR_STATUS value is 3901, indicating that a resource could not be obtained immediately, the request has not been serviced and the program should perform alternative processing before reissuing the NOWAIT request.
Tests the availability of the specified resources. If TEST is specified, the program should check the ERROR_STATUS field in the IDMS DC communications block to determine the outcome of the test.
Specifies the character ID that names the resource. Resource-id must be a user-defined field that contains the resource ID. The resource ID is a 1 to 255 byte character string used to identify the resource upon which an enqueue is to be set or tested. Any character string may be defined as long as all programs that access the resource use the same name and the name is unique relative to all other names used to identify other resources within the CV.
Specifies the symbolic name of either a user-defined FIXED BINARY(31) field that contains the length of the resource ID or the length itself expressed as a numeric constant.
Assigns the exclusive or shared attribute to the named resource. The default attribute is EXCLUSIVE.
The following statement enqueues the CODE_VALUE and PAYROLL_LOCK resources. CODE_VALUE is reserved for exclusive use by the issuing task; PAYROLL_LOCK can be shared.
ENQUEUE WAIT NAME (CODE_VALUE) LENGTH (10) NAME (PAYROLL_LOCK) LENGTH (16) SHARED;
The following statement tests the availability of the resource whose identifier is contained in the RESOURCE_NAME field:
ENQUEUE TEST NAME (RESOURCE_NAME) LENGTH (RESOURCE_NAME_LENGTH);
Upon completion of an ENQUEUE function to acquire resources, the ERROR_STATUS field in the IDMS DC communications block indicates the outcome of the operation:
The request has been serviced successfully.
At least one of the requested resources cannot be enqueued immediately; to wait would cause a deadlock. No new resources have been acquired.
At least one of the requested exclusive resources is currently owned by another task. No new resources have been acquired.
The parameter list is invalid.
Upon completion of an ENQUEUE function to test resources, the ERROR_STATUS field in the IDMS DC communications block indicates the outcome of the operation:
All requested resources are available.
At least one of the tested resources is already owned by another task.
At least one of the tested resources is not yet owned by another task and is available to the issuing task.
The parameter list is invalid.
|
Copyright © 2014 CA.
All rights reserved.
|
|