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 13 of 44
2.6. Setup and Initialization
GTHREAD_INITIALIZE_( int32 Version, GThreadCB MainCB )
Description:
Initializes the GThread primitives. This includes setting all fields in MainCB to zero, followed by
initializing the thread list anchors, setting the stack origin to a special invalid value, storing
GTHREAD_VERSION into GTh_Marker, and saving the MainCB address in NonStop operating
system process state. May be called for either static or swapped threads.
Input:
Version - A version control field. The program must pass the value of GTHREAD_VERSION,
which is a literal declared in HGTHREAD and GTHREADH (gthread.h).
MainCB - The address of the original thread control block.
Return: int16
Returns zero if initialization completed successfully. Returns GT_BAD_VERSION if the Version
parameter isn’t compatible with the GThread library.
Considerations:
Any non-static MainCB swap area must be set up after return from GTHREAD_INITIALIZE_. If
the program uses swapped threads with the peer protocol, it must provide a swap area for the main
thread: it should assign the address and length via the GTH_SET_ALLOCATION_ call. For
swapped threads using the unthreaded master protocol, where no main-thread activation records are
swapped, it is prudent to invoke GTHREAD_SWAPAREA_INVALIDATE(MainCB).
GTHREAD_ORIGIN_SET_( GThreadCB MainCB )
Description:
Sets the main thread control block stack origin to the stack tip currently recorded in the MainCB
context. May be called for either static or swapped threads.
Input:
MainCB - The address of the thread control block that was established by
GTHREAD_INITIALIZE_.
Return: int16
Returns zero if the function succeeds. Returns GT_BAD_ORIGIN, GT_BAD_MAIN_CB, or
GT_BAD_MAIN_STATE if an error is detected.
Considerations:
Either this procedure or GTHREAD_ORIGIN_SET_MOD_ must be called once. See the discussion
and examples under "Usage" in Section 3.
GTHREAD_ORIGIN_SET_MOD_( GThreadCB MainCB, int32 moreStack, int32 moreRegStack )
Description:
Modifies and then sets the main thread control block mem and reg stack origins relative to the stack
tips currently recorded in the MainCB context. This function extends the
GTHREAD_ORIGIN_SET_ functionality to allow modification of the stack origins such that