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 31 of 44
Return: int16
Returns zero if the termination completed successfully. nonzero occurs if any error is detected; error
values are GT_BAD_CB, GT_BAD_CB_NEXT, or GT_BAD_CB_PREV.
Considerations:
CB should not designate the current thread or MainCB. Passing one of these control blocks produces
undefined behavior; the error is not detected.
The program must provide a routine to terminate an active thread; this is the FinalProc procedure
passed to GTHREAD_INITIATE_. The FinalProc must arrange to have some other thread (or
unthreaded code) call GTHREAD_TERMINATE_ and perform any required cleanup.
The FinalProc runs within its thread, which remains active until switching context to another thread;
the thread can even wait and be resumed while the FinalProc is active. The FinalProc must
ultimately activate some other thread or unthreaded context; it must not exit. If the FinalProc exits
after being invoked because the InitialProc exited, a SIGILL signal (Instruction Failure trap) is
generated on TNS/R and TNS/E.
A procedure can call the FinalProc directly to kill the thread without exiting from the InitialProc.