Block until a thread terminates
#include <sys/neutrino.h> int ThreadJoin( int tid, void** status ); int ThreadJoin_r( int tid, void** status );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The ThreadJoin() and ThreadJoin_r() kernel calls block until the thread specified by tid terminates. If status isn't NULL, the functions save the thread's exit status in the area pointed to by status. If the thread tid has already terminated, the functions immediately return with success and the status, if requested.
These functions are identical except in the way they indicate errors. See the Returns section for details.
Instead of using these kernel calls directly, consider calling pthread_join() or pthread_timedjoin(). |
When ThreadJoin() returns successfully, the target thread has been successfully terminated. Until this occurs, the thread ID tid isn't reused and a small kernel resource (a thread object) is retained.
You can't join a thread that's detached (see ThreadCreate() and ThreadDetach()).
The target thread must be joinable. Multiple pthread_join(), pthread_timedjoin(), ThreadJoin(), and ThreadJoin_r() calls on the same target thread aren't allowed.
The only difference between these functions is the way they indicate errors:
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
pthread_join(), pthread_timedjoin(), ThreadCreate(), ThreadDetach()