![]() |
![]() |
![]() |
Destroy a thread immediately
#include <sys/neutrino.h> int ThreadDestroy( int tid, int priority, void* status ); int ThreadDestroy_r( int tid, int priority, void* status );
libc
The ThreadDestroy() and ThreadDestroy_r() functions are identical except in the way they indicate errors. See the Returns section for details.
These kernel calls terminate the thread specified by tid. If tid is 0 then the calling thread is assumed. If tid is -1 then all threads in the process are destroyed. When multiple threads are destroyed, the destruction is scheduled one thread at a time at the priority specified by the priority argument. If priority is -1, then the priority of the calling thread is used.
If a terminated thread isn't detached, it makes the value specified by the status argument available to any successful join on it. Until another thread retrieves this value, the thread ID tid isn't reused and a small kernel resource (a thread object) is held in the system. If the thread is detached, then status is ignored and all thread resources are immediately released.
When the last thread is destroyed, the process terminates and all thread resources are released even if they're not detached and unjoined.
![]() |
Upon return from ThreadDestroy() or ThreadDestroy_r(), the target thread will be marked for death but if it isn't possible to kill it immediately, it may not be terminated until it attempts to run. |
If these calls return, they don't block.
If the calling thread is destroyed, ThreadDestroy() or ThreadDestroy_r() won't return.
The only difference between these functions is the way they indicate errors:
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
ThreadCancel(), ThreadCreate()
![]() |
![]() |
![]() |