1

In Solaris, thr_join documentation states the following:

int  thr_join(thread_t  thread,  thread_t  *departed,   void
     **status);
If the target thread ID is  0, thr_join() finds and  returns
     the status of a terminated undetached thread in the process.

Is POSIX pthread_join equivalent?

 int pthread_join(pthread_t thread, void **status);

suspends processing of the calling thread until the target thread completes How can I use pthread_join in case of thr_join when I would like to know which child thread have terminated among many. Is there any other alternative? In other words, if a parent thread spawns N child threads, how do the parent thread know by polling or something else which thread has exited / terminated?

Dr. Debasish Jana
  • 6,980
  • 4
  • 30
  • 69

1 Answers1

0

Is POSIX pthread_join equivalent?

Yes, it's equivalent. Well, close enough. You can see the differences in the implementation:

int
thr_join(thread_t tid, thread_t *departed, void **status)
{
    int error = _thrp_join(tid, departed, status, 1);
    return ((error == EINVAL)? ESRCH : error);
}

/*
 * pthread_join() differs from Solaris thr_join():
 * It does not return the departed thread's id
 * and hence does not have a "departed" argument.
 * It returns EINVAL if tid refers to a detached thread.
 */
#pragma weak _pthread_join = pthread_join
int
pthread_join(pthread_t tid, void **status)
{
    return ((tid == 0)? ESRCH : _thrp_join(tid, NULL, status, 1));
}

They're even implemented using the same internal function.

But you don't want to use Solaris threads. Just use POSIX threads.

Community
  • 1
  • 1
Andrew Henle
  • 32,625
  • 3
  • 24
  • 56