Specifications

OpenVMS System Routines Called by OpenVMS AXP Device Drivers
IOC$ALLOC_CNT_RES
SS$_BADPARAM Request count was greater than the total number
of items managed by the CRAB or the total
number of items defined by a bounded request.
This status is also returned if the lower bound of
the request (CRCTX$L_LOW_BOUND) is greater
than the upper bound (CRCTX$L_UP_BOUND).
SS$_INSFMAPREG Insufficient resources to satisfy request.
Description
IOC$ALLOC_CNT_RES allocates a requested number of items from a counted
resource. The resource request is described in the CRCTX structure; the counted
resource itself is described in the CRAB.
A driver typically initializes the following fields of the CRCTX before submitting
it in a call to IOC$ALLOC_CNT_RES.
Field Description
CRCTX$L_ITEM_CNT Number of items to be allocated. When requesting
map registers, this value in this field should include
two extra map registers to be allocated and loaded
as guard pages to prevent runaway transfers.
CRCTX$L_CALLBACK Procedure value of the callback routine to be called
when the deallocation of resource items allows a
stalled resource request to be granted.
A value of 0 in this field indicates that, on an
allocation failure, control should return to the caller
immediately without queueing the CRCTX to the
CRAM’s wait queue.
A caller can also specify the upper and lower bounds of the search for allocatable
resource items by supplying values for CRCTX$L_LOW_BOUND and CRCTX$L_
UP_BOUND.
IOC$ALLOC_CNT_RES performs the following tasks:
It acquires the spin lock indicated by CRAB$L_SPINLOCK, raising IPL to
IPL$_IOLOCK11 in the process.
If there are no waiters for the counted resource (that is, the resource wait
queue headed by CRAB$L_WQFL is empty) or if the CRCTX describes a high-
priority allocation request (CRCTX$V_HIGH_PRIO in CRCTX$L_FLAGS is
set), IOC$ALLOC_CNT_RES attempts the allocation immediately. It scans
the CRAB allocation array for a descriptor that contains as many free items
as requested by the caller (in CRCTX$L_ITEM_CNT).
In performing the scan, IOC$ALLOC_CNT_RES considers any indicated
range of counted resource items that are to be involved in the scan, and limits
its search to those item descriptors in the allocation array that describe items
within these bounds. A bounded search is indicated by nonzero values in
CRCTX$L_UP_BOUND and CRCTX$L_LOW_BOUND. IOC$ALLOC_CNT_
RES rounds up the allocation request to the minimal allocation granularity,
as indicated by CRAB$L_ALLOC_GRAN_MASK.
A–3