User-Level Native Thread Primitives (GThread) Library White Paper (G06.26+)

User-Level Native Thread Primitives (GThread Library) 03/31/2005
Hewlett-Packard Company--540065-001 Page 22 of 46
GTH_STACK_CHECK_ACTIVE2_( GThread_CB cb, int32 mem_delta, int32 reg_delta )
Description:
Permits a client to determine whether there is a specified amount of stack space available on an
active static thread using the current stack pointers. Callable only for a static thread. This replaces
accessing the thread control block elements StackSize, StackOrigin, and performing a check
against the current value of the stack pointer (sp).
Input:
cb - The address of the currently active thread control block.
mem_delta - An indication of how much bigger the mem stack could potentially grow, in bytes.
reg_delta - An indication of how much bigger the reg stack could potentially grow, in bytes. This
argument is ignored on platforms other than TNS/E native.
Return: int16
Returns zero if there is available stack space.
Returns nonzero if:
The thread model is swapped
The stack space wasn’t allocated
A negative mem_delta or reg_delta was supplied
There is insufficient stack space available after applying mem_delta and reg_delta
Considerations:
For TNS/E native platforms, this interface applies mem_delta to the current mem stack pointer and
reg_delta to the current reg stack pointer. The resulting values are compared to the stack area
allocated. If either of the resulting values is outside the allocated area, this routine returns that there
is insufficient stack space. A value of zero for mem_delta and/or reg_delta is valid; it results in a
check to see if the corresponding stack for the active thread is currently in an overflow condition.
For TNS and TNS/R, the contents of reg_delta are ignored and the routine functions in the same
manner as GTH_STACK_CHECK_ACTIVE_.
This routine requires the thread control block of the currently active thread to perform the check. An
invalid comparison results when a suspended thread control block is provided to this interface.