Follow the change in kernel, joiner thread just waits at thread id
address, let kernel wake it up.
This commit is contained in:
parent
4938faa635
commit
d7f119abd5
@ -128,10 +128,13 @@ _pthread_exit(void *status)
|
||||
THR_GCLIST_ADD(curthread);
|
||||
curthread->state = PS_DEAD;
|
||||
THREAD_LIST_UNLOCK(curthread);
|
||||
if (curthread->joiner)
|
||||
_thr_umtx_wake(&curthread->state, INT_MAX);
|
||||
if (SHOULD_REPORT_EVENT(curthread, TD_DEATH))
|
||||
_thr_report_death(curthread);
|
||||
|
||||
/*
|
||||
* Kernel will do wakeup at the address, so joiner thread
|
||||
* will be resumed if it is sleeping at the address.
|
||||
*/
|
||||
thr_exit(&curthread->tid);
|
||||
PANIC("thr_exit() returned");
|
||||
/* Never reach! */
|
||||
|
@ -76,10 +76,10 @@ join_common(pthread_t pthread, void **thread_return,
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct timespec ts, ts2, *tsp;
|
||||
void *tmp;
|
||||
long state;
|
||||
long tid;
|
||||
int oldcancel;
|
||||
int ret = 0;
|
||||
|
||||
|
||||
if (pthread == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
@ -107,7 +107,8 @@ join_common(pthread_t pthread, void **thread_return,
|
||||
THR_CLEANUP_PUSH(curthread, backout_join, pthread);
|
||||
oldcancel = _thr_cancel_enter(curthread);
|
||||
|
||||
while ((state = pthread->state) != PS_DEAD) {
|
||||
tid = pthread->tid;
|
||||
while (pthread->tid != TID_TERMINATED) {
|
||||
if (abstime != NULL) {
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
TIMESPEC_SUB(&ts2, abstime, &ts);
|
||||
@ -118,7 +119,7 @@ join_common(pthread_t pthread, void **thread_return,
|
||||
tsp = &ts2;
|
||||
} else
|
||||
tsp = NULL;
|
||||
ret = _thr_umtx_wait(&pthread->state, state, tsp);
|
||||
ret = _thr_umtx_wait(&pthread->tid, tid, tsp);
|
||||
if (ret == ETIMEDOUT)
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user