#include <nitro/os.h>
void OS_SetThreadDestructor( OSThread* thread, OSThreadDestructor dtor );
thread | Pointer to the thread structure used to set the destructor |
dtor | Destructor function |
None.
This function sets the destructor function to be called when a thread ends.
The thread is specified by thread.dtor is a pointer to a function of OSThreadDestructor
type. The OSThreadDestructor
type is defined as follows.
typedef void (*OSThreadDestructor)( void* );
The destructor function is called when a thread ends under the following conditions.
-When the thread finishes executing its task
-When it ends withOS_ExitThread()
-When terminated from another thread usingOS_KillThread*()
- When it terminates itself withOS_KillThread*()
A destructor function is not called in the following situations.
EAnother thread usingOS_DestroyThread()
terminates the thread
-When the thread terminates itself usingOS_DestroyThread()
When the destructor function is executed, execution switches to the context of the thread that is terminated. The stack pointer is then updated (described later). The destructor is called before internal thread information is changed. Interrupts are disabled during this time.
The stack for executing the destructor function is updated to have the highest priority (excluding code used for checking) by default. You can change it to the specified stack using OS_SetThreadDestructorStack()
.
OS_InitThread,
OS_ExitThread, OS_DestroyThread, OS_KillThread*
OS_GetThreadDestructor, OS_SetThreadDestructorStack
2005/08/09 Added description of OS_SetThreadDestructorStack
.
07/07/2005 Added description of conditions under which the destructor is called.
06/30/2005 Initial version.