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 19 of 46
GTH_STACK_USED_( GThread_CB cb )
Description:
Returns the number of bytes of allocated stack space that is currently in use on the user stack.
Callable for either static or swapped threads. Replaces accessing the thread control block element
StackUsed.
Input:
cb -The address of the thread control block being checked.
Return: int32
Returns the amount of stack space being used in bytes at the point where GTHREAD_SETJMP_
was last called.
Considerations:
This interface returns stack usage information captured at the last call to GTHREAD_SETJMP_
when the thread was active. It is provided for users of swapped threads who wish to manage swap-
area overflow. This interface should not be used to monitor stack usage on a running thread; its
result is valid only after a call to GTHREAD_SETJMP_.
For TNS/E threads, the returned value is the sum for both stack components.
GTH_SET_ALLOCATION_( GThread_CB cb, void * saveArea, int32 size )
Description:
Permits a client to change the swap area. This is primarily used as part of swap area overflow
avoidance in swapped stack threading implementations. Callable only for a swapped thread.
Replaces accessing (modifying) the thread control block elements SwapArea and StackSize,
Input:
cb - The address of the thread control block being modified
saveArea - A pointer to the new save area
size - The size of the new save area in bytes.
Return: int16
Returns zero if change completed successfully. nonzero indicates the change failed because the
interface tried to adjust the swap area of a static thread.
Considerations:
The caller is responsible for disposing of the current swap area, typically before calling this routine.
This call must occur when the contents of the current swap area are no longer needed. Typically, for
handling swap area overflows, this routine is called as part of saving a suspending thread’s stack and
the stack saved after calls to GTHREAD_SETJMP_ and GTH_STACK_USED_. Refer to Section
2.4 for buffer alignment considerations.