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 20 of 44
stack_delta - An indication of how much bigger the mem stack could potentially grow, in bytes.
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 stack_delta was supplied
There is insufficient stack space available after applying stack_delta
Considerations:
This interface applies stack_delta to the current stack pointer, and compares the resulting value to
the stack area allocated. If the resulting value is outside the allocated area, this interface returns an
indication that there is insufficient stack space. A value of zero for stack_delta is valid; it results in a
check to see if the stack is currently in an overflow condition.
On TNS/E native platforms both the reg and mem stacks are checked. stack_delta is treated as the
memory ‘stack delta’ and a reg ‘stack delta’ is implicitly calculated from stack_delta. The implicit
calculation is based on the ‘ratio’ of mem stack to reg stack size that was established for the
specified thread at initialization time refer to Section 3.6.2 for more details.
This routine must be passed the thread control block of the currently active thread; passing a
suspended thread control block to this interface results in an invalid comparison.
GTH_STACK_CHECK_THREAD_( GThread_CB cb, int32 stack_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 thread control block to check.
stack_delta - An indication of how much bigger the mem stack could potentially grow, in bytes.
Return: int16
Returns zero if there is available stack space.
Returns nonzero if:
The thread model is swapped
Stack space wasn’t allocated
A negative stack_delta was supplied
There is insufficient stack space available after applying stack_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. The routine
applies stack_delta to the captured stack pointer, and compares the resulting value to the stack area
allocated. If the resulting value is outside the allocated area, this routine returns an indication that
there is insufficient stack space. A value of zero for stack_delta is valid; it results in a check to see if