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 44 of 44
where stack_delta or mem_delta and reg_delta are set to 0 to mimic the
previous method of examining StackUsed to determine if an overflow
condition existed at the time GTHREAD_SETJMP_ was last called.
For pre-checking:
GTH_STACK_CHECK_ACTIVE_( GThread_CB cb, int32 stack_delta )
GTH_STACK_CHECK_ACTIVE2_( GThread_CB cb, int32 mem_delta, int32 reg_delta )
where stack_delta or mem_delta and reg_delta are set according to the
user’s estimate of additional stack space required.
Certain clients of the GThread library access the thread control block elements StackOrigin and
StackSize to determine the location and size of the allocated stack for a thread during normal
operation. For TNS/E platforms, rather than directly accessing the thread control block, those
clients requiring this information need to use the following interfaces:
GTH_ALLOCATED_BASE_( GThread_CB cb )
GTH_ALLOCATED_SIZE_( GThread_CB cb )
Protected stacks provide an efficient alternative to the first approach. There is a guard area, but it
is protected (inaccessible), so any attempt to write or read in that area causes a fault. As with
unprotected guard areas, there is the possibility that activation of a procedure containing a large
data aggregate could “step over” the guard. However, the minimum protected guard area is 16
KB, which is much larger than a typical pattern guard, and no program logic or processing time is
required to scan it at thread context switches.