From 9ba1f9fa381dcbfb861533fdda13f9f27da78f14 Mon Sep 17 00:00:00 2001 From: deischen Date: Fri, 24 May 2002 04:32:28 +0000 Subject: 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 . Correct some minor style nits. --- lib/libpthread/thread/thr_sig.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/libpthread/thread/thr_sig.c') 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); } } -- cgit v1.1