Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/threadjoin.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/threadjoin.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/threadjoin.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/threadjoin.html on line 8

ThreadJoin(), ThreadJoin_r()

Block until a thread terminates

Synopsis:

#include <sys/neutrino.h>

int ThreadJoin( int tid,
                void** status );


int ThreadJoin_r( int tid,
                  void** status );

Arguments:

tid
The ID of the thread that you want to detach, as returned by ThreadCreate().
status
The address of a pointer to a location where the function can store the thread's exit status.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

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.


Note: 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.

Blocking states

STATE_JOIN
The calling thread blocks waiting for the indicated thread to exit.

Returns:

The only difference between these functions is the way they indicate errors:

ThreadJoin()
If an error occurs, the function returns -1 and sets errno. Any other value returned indicates success.
ThreadJoin_r()
Returns EOK on success. This function does NOT set errno. If an error occurs, the function may return any value listed in the Errors section.

Errors:

EBUSY
Attempt to join a thread which has been joined by another thread.
EDEADLK
Attempt to join to yourself.
EFAULT
A fault occurred when the kernel tried to access status.
EINTR
The call was interrupted by a signal.
EINVAL
Attempt to join a thread which is detached (see ThreadDetach()).
ESRCH
The thread indicated by tid doesn't exist.
ETIMEDOUT
A kernel timeout unblocked the call. See TimerTimeout().

Classification:

QNX Neutrino

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

pthread_join(), pthread_timedjoin(), ThreadCreate(), ThreadDetach()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/threadjoin.html on line 224

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/threadjoin.html on line 224