#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 type OSThreadDestructor
. The OSThreadDestructor
type is defined as:
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 ended withOS_ExitThread()
- When it was terminated from another thread withOS_KillThread*()
- When it terminated itself withOS_KillThread*()
A destructor function is not called in the following situations.
- When the thread was terminated by another thread usingOS_DestroyThread()
- When the thread terminated itself usingOS_DestroyThread()
When the destructor function is run, execution switches to the context of the thread that ends. The stack pointer is then updated (described later). The destructor is called while the thread is in interrupt-prohibited state, before internal thread information is changed.
At the time the destructor function is executed, the stack is shifted to highest priority by default (excluding the code used for checking). You can change it to the specified stack using OS_SetThreadDestructorStack()
.
Do not release the prohibition on interrupts inside the destructor function or call any functions that generate thread scheduling, because this may cause mismatching to arise in the thread list.
OS_InitThread
, OS_ExitThread
, OS_DestroyThread
, OS_KillThread*
, OS_GetThreadDestructor
, OS_SetThreadDestructorStack
2007/08/20 Added notes about operations inside the destructor function.
2005/08/09 Added text about OS_SetThreadDestructorStack
.
2005/07/07 Added text about conditions under which destructor function is called.
2005/06/30 Initial version.
CONFIDENTIAL