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 33 of 46
2.13. Termination
GTHREAD_TERMINATE_( GThread_CB cb )
Description:
Terminates the thread and delinks it from the list of threads. Callable for either static or swapped
threads.
Input:
cb - The address of the defunct thread control block, which should be inactive.
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.