summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_sig.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2002-05-24 04:32:28 +0000
committerdeischen <deischen@FreeBSD.org>2002-05-24 04:32:28 +0000
commit9ba1f9fa381dcbfb861533fdda13f9f27da78f14 (patch)
tree15691e04d3960954bb9843fcfd9d5beaf2553f80 /lib/libpthread/thread/thr_sig.c
parentabd4f3d6cc97e6f9042d207b7f1442f11860e88d (diff)
downloadFreeBSD-src-9ba1f9fa381dcbfb861533fdda13f9f27da78f14.zip
FreeBSD-src-9ba1f9fa381dcbfb861533fdda13f9f27da78f14.tar.gz
Revamp suspend and resume. While I'm here add pthread_suspend_all_np()
and pthread_resume_all_np(). These suspend and resume all threads except the current thread, respectively. The existing functions pthread_single_np() and pthread_multi_np(), which formerly had no effect, now exhibit the same behaviour and pthread_suspend_all_np() and pthread_resume_all_np(). These functions have been added mostly for the native java port. Don't allow the uthread kernel pipe to use the same descriptors as stdio. Mostily submitted by Oswald Buddenhagen <ossi@kde.org>. Correct some minor style nits.
Diffstat (limited to 'lib/libpthread/thread/thr_sig.c')
-rw-r--r--lib/libpthread/thread/thr_sig.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/libpthread/thread/thr_sig.c b/lib/libpthread/thread/thr_sig.c
index 1bd93b7..7aa9b53 100644
--- a/lib/libpthread/thread/thr_sig.c
+++ b/lib/libpthread/thread/thr_sig.c
@@ -54,7 +54,7 @@ static void thread_sigframe_save(struct pthread *thread,
static void thread_sig_invoke_handler(int sig, siginfo_t *info,
ucontext_t *ucp);
-/* #define DEBUG_SIGNAL */
+/*#define DEBUG_SIGNAL*/
#ifdef DEBUG_SIGNAL
#define DBG_MSG stdout_debug
#else
@@ -375,7 +375,8 @@ thread_sig_find(int sig)
return (NULL);
}
else if ((handler_installed != 0) &&
- !sigismember(&pthread->sigmask, sig)) {
+ !sigismember(&pthread->sigmask, sig) &&
+ ((pthread->flags & PTHREAD_FLAGS_SUSPENDED) == 0)) {
if (pthread->state == PS_SIGSUSPEND) {
if (suspended_thread == NULL)
suspended_thread = pthread;
@@ -791,10 +792,17 @@ thread_sig_add(struct pthread *pthread, int sig, int has_args)
/*
* The thread should be removed from all scheduling
* queues at this point. Raise the priority and place
- * the thread in the run queue.
+ * the thread in the run queue. It is also possible
+ * for a signal to be sent to a suspended thread,
+ * mostly via pthread_kill(). If a thread is suspended,
+ * don't insert it into the priority queue; just set
+ * its state to suspended and it will run the signal
+ * handler when it is resumed.
*/
pthread->active_priority |= PTHREAD_SIGNAL_PRIORITY;
- if (thread_is_active == 0)
+ if ((pthread->flags & PTHREAD_FLAGS_SUSPENDED) != 0)
+ PTHREAD_SET_STATE(pthread, PS_SUSPENDED);
+ else if (thread_is_active == 0)
PTHREAD_PRIOQ_INSERT_TAIL(pthread);
}
}
OpenPOWER on IntegriCloud