User-Level Native Thread Primitives (GThread) Library White Paper (G06.27+, H06.03+, J06.03+)

User-Level Native Thread Primitives (GThread Library) 02/15/2012
540065-004 Page 22 of 44
GTH_STACK_CHECK_THREAD2_( 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 a static
thread using stack pointer information captured on the last call to GTHREAD_SETJMP_ for the
specified thread. May be called only for an unprotected static thread. This replaces accessing the
thread control block elements StackSize and StackUsed.
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:
This routine is used to detect if sufficient stack space is available based on the stack pointer
information captured in the last call to GTHREAD_SETJMP_ by the specified thread. For TNS/E
native platforms, this interface applies mem_delta to the captured mem stack pointer and reg_delta
to the captured 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 an indication 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 an overflow condition existed on the corresponding stack at the time
GTHREAD_SETJMP_ was called to capture stack pointer information.
Note: For TNS and TNS/R, the contents of reg_delta are ignored and the routine functions in the
same manner as GTH_STACK_CHECK_THREAD_.
This interface returns information based on the last call to GTHREAD_SETJMP_, or to
GTHREAD_INITIATE_ if GTHREAD_SETJMP_ has not yet been called. This interface is intended
for use on suspended threads. For an active thread, the results are accurate only within the function
that called GTHREAD_SETJMP_.
GTH_STACK_ORIGIN_( GThread_CB cb )
Description:
Returns the stack origin used by the thread. May be called for either static or swapped threads. This
replaces accessing the thread control block element StackOrigin.
Input:
cb - The address of the thread control block.