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 16 of 44
local to a procedure (such as the one that invokes GTHREAD_INITIATE_) that will exit
immediately. It must not designate anything local to any swapped thread.
To avoid architecture dependencies in parameter passing, the initial procedure should have a simple
calling sequence (not EXTENSIBLE or VARIABLE) with a fixed number of 32-bit parameters,
such as INT(32) values or INT/STRING .EXT pointers. (In native C/C++, or TNS C with the wide
model, parameters should be int or pointer values.) Thus, when ArgStart designates an array of N
32-bit values, ArgLen is 4*N. (Without these restrictions, the program must account for architecture-
dependent alignment and width requirements for passing 16- or 64-bit arguments, and must provide
any VARIABLE/EXTENSIBLE mask/count words, which differ in format and placement between
TNS, TNS/R, and TNS/E calls.)
On TNS/E platforms, the GThread implementation is restricted to a maximum of eight 32-bit or 64-
bit parameters, one per 64-bit register. On TNS/R or TNS platforms, a 64-bit parameter can occupy
multiple slots, but not on TNS/E, where each parameter is sign-extended and placed in a 64-bit
register. The same restriction makes it impossible to create a valid VARIABLE/EXTENSIBLE
mask.
The argument list cannot combine arguments of different widths (32-bit and 64-bit). It must point to
a string (or array) of only 32-bit or 64-bit fields.
For a 64-bit application, the argument list can be an array of 64-bit wide values. HP recommends
that a 64-bit client always use 64-bit fields instead of 32-bit fields so that it can use 64-bit pointers
when required. If an application wants to use 64-bit fields, then it must also set the GTS_ARG_64
flag in the Swaptions parameter. This flag ensures that the argument list is interpreted as an array of
8-byte arguments. Otherwise, the argument list is taken as an array of 4-byte fields. If there is a
mismatch between the arguments’ width and the Swaptions bit, the results are undefined.
For TNS threads: Start, Length, ArgStart and ArgLen must be even, and @CB.StackOrigin + Length
must be positive and less than 65536d.
For native threads:
ArgStart and ArgLen must be multiples of 4
For Swaptions parameter GTS_ARG_64, ArgStart and ArgLen must be multiples of 8
For swapped threads, Start must be a multiple of 4 on TNS/R or 8 on TNS/E
For static threads, Start must be a multiple of 8 on TNS/R or 16 on TNS/E
For unprotected stacks, Length must be less than 32 MB and a multiple of 8 on TNS/R or 16
on TNS/E
For protected stacks, the stack must be allocated by STACK_ALLOCATE_(). Length must
be at least 48 KB and not more than 16 MB.
The FinalProc procedure, which takes one GThread_CB parameter designating the current (expiring)
thread, is further discussed below under "Termination” in Section 2.13
.