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 15 of 46
2.7. Initiation
A program creates a new thread by allocating a GThread_CB and a stack area, and invoking the
following procedure.
GTHREAD_INITIATE_( GThreadCB CB,GThreadCB MainCB,
void *Start, int32 Length,
int16 Swaptions,
GTH_FUNC InitialProc,
void *ArgStart, int32 ArgLen,
GTH_FUNC FinalProc)
Description:
Initiates a thread by setting up the thread control block, building an initial stack image, and linking
the new thread onto the list of threads. Callable for either static or swapped threads.
Input:
CB - The address of the thread control block for the new thread.
MainCB - The address of the main thread control block that designates the initial processing
environment, as established by GTHREAD_INITIALIZE.
Start - The starting (lowest) address of the stack area provided for the new thread. (For a
swapped thread, this is the swap area.)
Length - The length allocated for the new thread stack.
Swaptions - Characterizes static and swapped threads:
GTS_STATIC specifies a static thread.
GTS_SWAPPED specifies a swapped thread.
GTS_DISCONTIGUOUS can be added to GTS_SWAPPED to specify that the swap area is not a
contiguous area designated by CB.SwapArea. Diagnostic programs cannot display
inactive threads that have discontiguous stacks.
GTS_STATIC_FILL and GTS_STATIC_RegPerCent (n) can be added to GTS_STATIC.
GTS_STATIC_FILL causes the stack to be filled with a fixed pattern for determining
stack usage.
GTS_STATIC_RegPerCent(n) specifies the percentage of the Length value to be used
for the register stack on TNS/E platforms. This provides for greater control of the mem
stack and reg stack allocation. See Section 2.11 and Section 3.6.2 for more information.
InitialProc - An untyped procedure that is invoked to begin the new thread.
ArgStart and ArgLen - The address and byte length of a string of argument values to be passed to
the InitialProc.
FinalProc - The procedure to invoke when the initial procedure of the thread exits.