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 29 of 44
GTHREAD_LONGJMP_( GThread_CB cb, int32 val, GTH_FUNC Callee )
Description:
An augmented implementation of the C longjmp() function. This procedure returns to the site of the
previous GTHREAD_SETJMP_ call for the designated thread. May be called for either static or
swapped threads.
Input:
cb – The address of a thread control block containing the target context. On TNS/E, this
must be aligned on a 16-byte boundary
val - The value to be returned; 0d causes return of 1d.
Callee- GTH_NULL_PROCADDR or a pointer to a parameterless, untyped procedure. If
the Callee pointer is not null, the resumed thread will call the designated procedure
from the target site.
Return: void
Considerations:
GTHREAD_LONGJMP_ causes a SIGFPE signal (Arithmetic Overflow trap) on TNS/R and a
SIGILL signal (Instruction Failure) on TNS/E if the CB was not set up by GTHREAD_SETJMP_, or
if GTHREAD_SETJMP_ was called from privileged code but GTHREAD_LONGJMP_ was not.
(Such signals/traps may occur due to inconsistencies detected in any of several procedures, each of
which contains "LONGJMP" or "longjmp" in its name.) Also, GTHREAD_LONGJMP_ causes a
SIGILL signal on TNS/E if the GThread control block isn’t aligned on a 16-byte boundary.
GTHREAD_SWAPIN_SETUP_( GThread_CB cb, GTH_FUNC ResumeProc )
Description:
Starts the sequence to swap in a thread. This procedure MUST be called for a swapped thread but
must NOT be called for a static thread
Input:
cb – The address of the thread to activate.
ResumeProc - Designates an untyped procedure with one parameter, the CB of the thread to be
swapped in. This procedure includes any thread-package code needed to activate the
thread, including (in particular) the code to swap in the stack.
Return: void
Considerations:
GTHREAD_SWAPIN_SETUP_ adjusts the stack pointer to be deeper than any of the stack frames
to be swapped in. Then it calls the ResumeProc, passing CB; the ResumeProc must not return.
If the CB was not set up by the GTHREAD_SETJMP_ function, then calling this function will
generate a SIGFPE signal (Arithmetic Overflow trap) on TNS/R and a SIGILL (Illegal Instruction)
on TNS/E.