summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_thr.c
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2005-10-26 06:55:46 +0000
committerdavidxu <davidxu@FreeBSD.org>2005-10-26 06:55:46 +0000
commit23ec020060d0889d45cd07e2d8f578498aeab4c0 (patch)
tree10643dea8fac4c97e9990b0c1940052d5bc1d7f2 /sys/kern/kern_thr.c
parenta16098473846c54b54bd1b74ca434605687746c7 (diff)
downloadFreeBSD-src-23ec020060d0889d45cd07e2d8f578498aeab4c0.zip
FreeBSD-src-23ec020060d0889d45cd07e2d8f578498aeab4c0.tar.gz
do umtx_wake at userland thread exit address, so that others userland
threads can wait for a thread to exit, and safely assume that the thread has left userland and is no longer using its userland stack, this is necessary for pthread_join when a thread is waiting for another thread to exit which has user customized stack, after pthread_join returns, the userland stack can be reused for other purposes, without this change, the joiner thread has to spin at the address to ensure the thread is really exited.
Diffstat (limited to 'sys/kern/kern_thr.c')
-rw-r--r--sys/kern/kern_thr.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c
index e6661e2..39817df 100644
--- a/sys/kern/kern_thr.c
+++ b/sys/kern/kern_thr.c
@@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$");
#include <sys/signalvar.h>
#include <sys/ucontext.h>
#include <sys/thr.h>
+#include <sys/umtx.h>
+#include <sys/limits.h>
#include <machine/frame.h>
@@ -275,8 +277,10 @@ thr_exit(struct thread *td, struct thr_exit_args *uap)
p = td->td_proc;
/* Signal userland that it can free the stack. */
- if ((void *)uap->state != NULL)
+ if ((void *)uap->state != NULL) {
suword((void *)uap->state, 1);
+ kern_umtx_wake(td, uap->state, INT_MAX);
+ }
PROC_LOCK(p);
sigqueue_flush(&td->td_sigqueue);
OpenPOWER on IntegriCloud