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 9 of 44
• STRING .EXT StackStart and INT(32) StackUsed are the starting (lowest) address and byte length
of the in-use mem stack area, set by GTHREAD_SETJMP_ for use by the program for swapping or
checkpointing.
• STRUCT GThread_Private (GThread_Private_Template) is a private structure for GThread (an
augmented jump buffer).
2.4. Alignment Considerations
The alignment considerations for stack/swap space vary with the platform and the thread model. Both the
starting address and the length of the area must be divisible by the alignment that applies. The following
table indicates the minimum alignment required based on platform and thread model:
Platform
Swapped
Static
TNS
2 2
TNS/R native
4
8
TNS/E native
8 16
The standard dynamic memory-allocation functions on each platform, such as malloc(),
POOL_GETSPACE_(), and STACK_ALLOCATE_(), provide memory blocks suitably aligned for static
threads. However, a statically allocated global stack area requires care to achieve proper alignment:
The alignment of a static stack area, such as an array or structure, is the largest alignment of its elements.
Consequently, on TNS/R native, an array or structure must contain an 8-byte element to force alignment
on an 8-byte boundary. On TNS/E native, a 16-byte fundamental type does not exist for alignment
purposes. Instead, a pragma has been added to C/C++, which indicates maximum alignment of 16 bytes
for the objects to which it refers. For EpTAL a structure attribute has been added to effect proper
alignment. Both the C/C++ pragma and the EpTAL attribute are called MAXALIGN and are not
backwards compatible with TNS/R.
Note that all TNS/E native thread control blocks must be 16-byte aligned. No such requirement exists for
TNS/R.
2.5. Literals and Defines
IF_TNS__(TNS_code, MIPS or IPF native_code)
expands to the text of the first parameter in TNS compilations and the second parameter in native
compilations. For short sequences, the macro may offer more readable source code than equivalent use
of the following directives or their C equivalents:
?IFNOT PTAL
TNS_code
?ENDIF PTAL
?IF PTAL
native_code
?ENDIF PTAL
IF_TNS_MIPS_IPF__(TNS_code,Mips native_code, IPF native code)