Previous Topic: ENDPAGE (DC/UCF)Next Topic: ERASE


ENQUEUE (DC/UCF)

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:

Syntax
►►─── ENQUEUE ─┬──────────┬───────────────────────────────────────────────────►
               ├─ WAIT ◄ ─┤
               ├─ NOWAIT ─┤
               └─ TEST ───┘

   ┌─────────────────────────────────────────────────────────────────────┐
 ►─▼─ NAME (resource-id) LENGTH (resource-id-length) ──┬───────────────┬─┴ ; ─►◄
                                                       ├─ EXCLUSIVE ◄ ─┤
                                                       └─ SHARED ──────┘
Parameters
WAIT

Specifies that the system is to wait for all resources to be freed if it cannot service the request immediately. WAIT is the default.

NOWAIT

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.

TEST

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.

NAME (resource-id)

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.

LENGTH (resource-id-length)

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.

EXCLUSIVE/SHARED

Assigns the exclusive or shared attribute to the named resource. The default attribute is EXCLUSIVE.

Example

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);
Status Codes

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:

0000

The request has been serviced successfully.

3901

At least one of the requested resources cannot be enqueued immediately; to wait would cause a deadlock. No new resources have been acquired.

3908

At least one of the requested exclusive resources is currently owned by another task. No new resources have been acquired.

3931

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:

0000

All requested resources are available.

3908

At least one of the tested resources is already owned by another task.

3909

At least one of the tested resources is not yet owned by another task and is available to the issuing task.

3931

The parameter list is invalid.