_GTSEG - allocate a SEGID.
(GCOS8 only)
Usage:
C:
#include <climb.h>
ptr = _gtseg(svec);
PL6:
DCL X_GET_SEGID ENTRY(2);
X_GET_SEGID(svec,ptr);
Where:
- const struct _vector *svec;
- points to a shrink vector framing an area of memory.
- void *ptr;
- is the pointer value resulting from the shrink operation,
pointing to the beginning of the segment. The generated
SEGID can be extracted from the lowest 12 bits of this
pointer.
Description:
"_gtseg" allocates a SEGID for the descriptor
generated by a shrink operation on "svec". In order to
allocate the SEGID, "_gtseg" follows these steps:
- First, it looks to see if there are any unused slots in
the Linkage Segment. Slots are unused if they were
originally allocated through LKED as free slots
(discussed below) or if the corresponding SEGID has been
freed by a call to "_frseg".
- If there is no space left in the Linkage Segment,
"_gtseg" next looks for open slots in the
Argument Stack. Open slots can arise in two ways: gaps
left when previously allocated SEGIDs are freed via
"_frseg"; and slots marked unused after a
"_restore_arg_stack" operation. If there is an
open slot, "_gtseg" uses it.
- If there are no open slots in the Argument Stack,
"_gtseg" allocates a SEGID by using an SDR
instruction to push a new descriptor onto the Argument
Stack. If the Argument Stack is already full, the SDR
instruction causes a fault.
In other words, "_gtseg" uses the Linkage Segment
until it is full, then switches to the Argument Stack. Programs
don't have to do their own checking to determine whether they
should use the Linkage Segment or the Argument Stack.
If the descriptor resulting from the shrink operation doesn't
have save permission, "_gtseg" always uses (c) above;
in other words, it always allocates the slot on the Argument
Stack.
Restricting Allocation to the Linkage Segment:
You can set up "_gtseg" so that it only allocates
from the Linkage Segment, without switching over to the Argument
Stack. If you are linking your program with LD, specify
Use=NO_LS_OVERFLOW
in the LD input. If you are linking your program with LKED,
specify
CREATE_REFERENCE -SYMREF NO_LS_OVERFLOW
This gives you a version of "_gtseg" that allocates
from the Linkage Segment only, not from the Argument Stack.
Argument Stack Map:
The software underlying "_gtseg" maintains a map
describing all of the slots allocated in the Argument Stack. Each
slot has one of four possible statuses:
- The slot holds a savable descriptor (one that should be
saved if the program calls "_save_arg_stack").
- The slot holds an unsavable descriptor (one with its save
permission bit turned off or one that was allocated with
"_gtlseg").
- The slot has been freed by a call to "_frseg".
- The slot's status is unknown. When "_gtseg"
allocates a new slot in the Argument Stack, it checks the
resulting SEGID against its count of the number of
descriptors already pushed onto the stack. If the count
differs from the SEGID, "_gtseg" concludes that
the program has pushed additional descriptors onto the
Argument Stack with its own SDR instructions. These
additional descriptors are marked as "unknown".
The file "expl nsc lib
_save_arg_stack" explains the effect of each of these
statuses when the Argument Stack is saved and restored over an
OCLIMB.
Free Slots in the Linkage Segment:
If you are linking your program with LD, all unused Linkage
Segment slots are available for allocation by "_gtseg".
If you are linking your program with LKED, you can make a
Linkage Segment slot available by using the -Managed_Slots option
of the Define_Domain directive. See your LKED documentation for
further details.
See Also:
- expl nsc lib _frseg
- for freeing SEGIDs allocated via "_gtseg".
- expl nsc lib _gtlseg
- for allocating a SEGID that will only be used during the
current invocation of the program (one that disappears
over an OCLIMB).
- expl nsc lib _gtsseg
- for marking a specific SEGID as busy.
- expl nsc lib _save_arg_stack
- for saving the Argument Stack before an OCLIMB.
- expl nsc lib _restore_arg_stack
- for restoring the Argument Stack after an OCLIMB.
Copyright © 1996, Thinkage Ltd.