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 24 of 44
Input:
cb - The address of the thread control block.
Return: GThread_CB
The address of the previous thread.
Considerations:
Provided for completeness.
2.10. Saving and Restoring Stacks
GTH_STACK_SAVE_( GThread_CB cb )
Description:
As part of suspending the current thread execution (dispatching another thread), performs a copy
(save) of the current thread’s runtime stack. This may be called only for a swapped thread. The
GTH_STACK_SAVE_ call replaces the access to the thread control block elements SwapArea,
StackStart, StackUsed, and copies the stack to the save area from the runtime stack area. For
swapped TNS or TNS/R native stacks, this call is optional. For swapped TNS/E native stacks, this
call is required to deal with the two parts of the stack, (main (data) area and the RSE area).
Input:
cb - The address of the current thread control block.
Return: int16
Returns zero if save completed successfully. nonzero indicates the copy failed due to a static thread
model, an invalidated or discontiguous swap area, or insufficient swap space.
Considerations:
This routine must be called after GTHREAD_SETJMP_ or by a function passed to be called by
GTHREAD_SETJMP_. See sections 3.2 and 3.6.3.1. The routine does not validate whether the
thread control block supplied belongs to the currently executing thread. If the control block of a
suspended thread is provided, corruption of the specified thread’s runtime environment occurs.
GTH_STACK_RESTORE_( GThread_CB cb )
Description:
Performs a restore of the target thread’s runtime stack as part of dispatching that thread. May be
called only for a swapped thread. This call replaces accessing the thread control block elements
SwapArea, StackStart, StackUsed, and copying the stack from the save area back to the runtime
stack area. For swapped TNS or TNS/R native stacks, this call is optional; explicit code can be
retained instead. For swapped TNS/E native stacks, this call is required to deal with the two parts of
the stack, (main (data) area and the RSE area).
Input:
cb - The address of the target thread control block whose stack needs to be restored.