summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_exit.c
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>1998-04-29 09:59:34 +0000
committerjb <jb@FreeBSD.org>1998-04-29 09:59:34 +0000
commit6c9ee23acc144ec10f869bbd9b872379224a8938 (patch)
treeb0024d273ef0465a33cf00f2b90524d004b9c0b1 /lib/libpthread/thread/thr_exit.c
parenta44088edc8056e79e7c0b3b27ea2c5c3355368e9 (diff)
downloadFreeBSD-src-6c9ee23acc144ec10f869bbd9b872379224a8938.zip
FreeBSD-src-6c9ee23acc144ec10f869bbd9b872379224a8938.tar.gz
Change signal model to match POSIX (i.e. one set of signal handlers
for the process, not a separate set for each thread). By default, the process now only has signal handlers installed for SIGVTALRM, SIGINFO and SIGCHLD. The thread kernel signal handler is installed for other signals on demand. This means that SIG_IGN and SIG_DFL processing is now left to the kernel, not the thread kernel. Change the signal dispatch to no longer use a signal thread, and call the signal handler using the stack of the thread that has the signal pending. Change the atomic lock method to use test-and-set asm code with a yield if blocked. This introduces separate locks for each type of object instead of blocking signals to prevent a context switch. It was this blocking of signals that caused the performance degradation the people have noted. This is a *big* change!
Diffstat (limited to 'lib/libpthread/thread/thr_exit.c')
-rw-r--r--lib/libpthread/thread/thr_exit.c46
1 files changed, 11 insertions, 35 deletions
diff --git a/lib/libpthread/thread/thr_exit.c b/lib/libpthread/thread/thr_exit.c
index 15bcfa3..4bc7da9 100644
--- a/lib/libpthread/thread/thr_exit.c
+++ b/lib/libpthread/thread/thr_exit.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
+ * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -102,9 +102,6 @@ pthread_exit(void *status)
long l;
pthread_t pthread;
- /* Block signals: */
- _thread_kern_sig_block(NULL);
-
/* Save the return value: */
_thread_run->ret = status;
@@ -126,6 +123,9 @@ pthread_exit(void *status)
PTHREAD_NEW_STATE(pthread,PS_RUNNING);
}
+ /* Lock the thread list: */
+ _lock_thread_list();
+
/* Check if the running thread is at the head of the linked list: */
if (_thread_link_list == _thread_run) {
/* There is no previous thread: */
@@ -153,39 +153,12 @@ pthread_exit(void *status)
}
}
- /* Check if this is a signal handler thread: */
- if (_thread_run->parent_thread != NULL) {
- /*
- * Enter a loop to search for other threads with the same
- * parent:
- */
- for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) {
- /* Compare the parent thread pointers: */
- if (pthread->parent_thread == _thread_run->parent_thread) {
- /*
- * The parent thread is waiting on at least
- * one other signal handler. Exit the loop
- * now that this is known.
- */
- break;
- }
- }
+ /* Unlock the thread list: */
+ _unlock_thread_list();
- /*
- * Check if the parent is not waiting on any other signal
- * handler threads and if it hasn't died in the meantime:
- */
- if (pthread == NULL && _thread_run->parent_thread->state != PS_DEAD) {
- /* Allow the parent thread to run again: */
- PTHREAD_NEW_STATE(_thread_run->parent_thread,PS_RUNNING);
- }
- /* Get the signal number: */
- l = (long) _thread_run->arg;
- sig = (int) l;
+ /* Lock the dead thread list: */
+ _lock_dead_thread_list();
- /* Unblock the signal from the parent thread: */
- sigdelset(&_thread_run->parent_thread->sigmask, sig);
- }
/*
* This thread will never run again. Add it to the list of dead
* threads:
@@ -193,6 +166,9 @@ pthread_exit(void *status)
_thread_run->nxt = _thread_dead;
_thread_dead = _thread_run;
+ /* Unlock the dead thread list: */
+ _unlock_dead_thread_list();
+
/*
* The running thread is no longer in the thread link list so it will
* now die:
OpenPOWER on IntegriCloud