Specifications

OpenVMS System Routines Called by OpenVMS AXP Device Drivers
IOC$DEALLOC_CNT_RES
Description
IOC$DEALLOC_CNT_RES deallocates a requested number of items of a
counted resource. The resource request is described in the CRCTX structure;
the counted resource itself is described in the CRAB. After deallocating the items,
IOC$DEALLOC_CNT_RES attempts to restart any waiters for the resource.
IOC$DEALLOC_CNT_RES performs the following tasks:
1. It examines CRCTX$V_ITEM_VALID in CRCTX$L_FLAGS. If it is clear,
IOC$DEALLOC_CNT_RES returns SS$_BADPARAM status to its caller.
2. It acquires the spin lock indicated by CRAB$L_SPINLOCK, raising IPL to
IPL$_IOLOCK in the process.
3. It scans the CRAB allocation array for a descriptor into which the items being
deallocated (indicated by CRCTX$L_ITEM_CNT) can be merged.
4. It adjusts the CRAB allocation array and CRAB$L_VALID_DESC_CNT to
reflect the deallocation.
5. If there are waiters for the counted resource, IOC$DEALLOC_CNT_RES
removes the CRCTX of the first waiter from the CRAB wait queue (CRAB$L_
WQFL) and calls IOC$ALLOC_CNT_RES to grant the requested number of
resources.
If this attempt succeeds, IOC$DEALLOC_CNT_RES restores the context
of the stalled waiter (R3 through R5), releases the spin lock indicated by
CRAB$L_SPINLOCK (upon the condition that the caller of IOC$DEALLOC_
CNT_RES did not already own this spin lock at the time of the call), and
issues a standard call to the callback routine indicated by CRCTX$L_
CALLBACK, passing it the address of the CRAB; the address of the CRCTX;
the values stored in CRCTX$Q_FR3, CRCTX$Q_FR4, and CRCTX$Q_FR5;
and SS$_NORMAL status.
IOC$DEALLOC_CNT_RES continues to attempt to restart waiters in this
manner until an allocation request fails. When this occurs, IOC$DEALLOC_
CNT_RES replaces its CRCTX in the CRAB wait queue, conditionally releases
the spin lock indicated by CRAB$L_SPINLOCK, and returns SS$_NORMAL
status to its caller.
6. If there are no waiters for the counted resource, IOC$DEALLOC_CNT_RES
conditionally releases the spin lock indicated by CRAB$L_SPINLOCK, and
returns SS$_NORMAL status to its caller.
A–24