From 59cc2dcac73d4a11a44dd324d1c102ac42288352 Mon Sep 17 00:00:00 2001 From: Daniel Eischen Date: Fri, 4 May 2001 20:37:07 +0000 Subject: Move the check for a pending signals to after the thread has been placed in any scheduling queue(s). The process of dispatching signals to a thread can change its state which will attempt to add or remove the thread from any scheduling queue to which it belongs. This can break some assertions if the thread isn't in the queue(s) implied by its state. When adding dispatching a pending signal to a thread, be sure to remove the signal from the threads set of pending signals. PR: 27035 Tested by: brian MFC in: 1 week --- lib/libc_r/uthread/uthread_kern.c | 21 +++++++++++++++------ lib/libc_r/uthread/uthread_sig.c | 3 +++ lib/libkse/thread/thr_kern.c | 21 +++++++++++++++------ lib/libkse/thread/thr_sig.c | 3 +++ lib/libpthread/thread/thr_kern.c | 21 +++++++++++++++------ lib/libpthread/thread/thr_sig.c | 3 +++ 6 files changed, 54 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/libc_r/uthread/uthread_kern.c b/lib/libc_r/uthread/uthread_kern.c index 8a3225335c65..9d317eda6cca 100644 --- a/lib/libc_r/uthread/uthread_kern.c +++ b/lib/libc_r/uthread/uthread_kern.c @@ -206,12 +206,6 @@ _thread_kern_scheduler(void) PANIC("Unable to restore alternate signal stack"); } - /* Are there pending signals for this thread? */ - if (curthread->check_pending != 0) { - curthread->check_pending = 0; - _thread_sig_check_pending(curthread); - } - /* * Enter a scheduling loop that finds the next thread that is * ready to run. This loop completes when there are no more threads @@ -335,6 +329,21 @@ _thread_kern_scheduler(void) PTHREAD_WORKQ_INSERT(curthread); break; } + + /* + * Are there pending signals for this thread? + * + * This check has to be performed after the thread + * has been placed in the queue(s) appropriate for + * its state. The process of adding pending signals + * can change a threads state, which in turn will + * attempt to add or remove the thread from any + * scheduling queue to which it belongs. + */ + if (curthread->check_pending != 0) { + curthread->check_pending = 0; + _thread_sig_check_pending(curthread); + } } /* diff --git a/lib/libc_r/uthread/uthread_sig.c b/lib/libc_r/uthread/uthread_sig.c index 71a88efe4a30..9ce53a0c702c 100644 --- a/lib/libc_r/uthread/uthread_sig.c +++ b/lib/libc_r/uthread/uthread_sig.c @@ -575,6 +575,9 @@ thread_sig_add(pthread_t pthread, int sig, int has_args) restart = _thread_sigact[sig - 1].sa_flags & SA_RESTART; + /* Make sure this signal isn't still in the pending set: */ + sigdelset(&pthread->sigpend, sig); + /* * Process according to thread state: */ diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c index 8a3225335c65..9d317eda6cca 100644 --- a/lib/libkse/thread/thr_kern.c +++ b/lib/libkse/thread/thr_kern.c @@ -206,12 +206,6 @@ _thread_kern_scheduler(void) PANIC("Unable to restore alternate signal stack"); } - /* Are there pending signals for this thread? */ - if (curthread->check_pending != 0) { - curthread->check_pending = 0; - _thread_sig_check_pending(curthread); - } - /* * Enter a scheduling loop that finds the next thread that is * ready to run. This loop completes when there are no more threads @@ -335,6 +329,21 @@ _thread_kern_scheduler(void) PTHREAD_WORKQ_INSERT(curthread); break; } + + /* + * Are there pending signals for this thread? + * + * This check has to be performed after the thread + * has been placed in the queue(s) appropriate for + * its state. The process of adding pending signals + * can change a threads state, which in turn will + * attempt to add or remove the thread from any + * scheduling queue to which it belongs. + */ + if (curthread->check_pending != 0) { + curthread->check_pending = 0; + _thread_sig_check_pending(curthread); + } } /* diff --git a/lib/libkse/thread/thr_sig.c b/lib/libkse/thread/thr_sig.c index 71a88efe4a30..9ce53a0c702c 100644 --- a/lib/libkse/thread/thr_sig.c +++ b/lib/libkse/thread/thr_sig.c @@ -575,6 +575,9 @@ thread_sig_add(pthread_t pthread, int sig, int has_args) restart = _thread_sigact[sig - 1].sa_flags & SA_RESTART; + /* Make sure this signal isn't still in the pending set: */ + sigdelset(&pthread->sigpend, sig); + /* * Process according to thread state: */ diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c index 8a3225335c65..9d317eda6cca 100644 --- a/lib/libpthread/thread/thr_kern.c +++ b/lib/libpthread/thread/thr_kern.c @@ -206,12 +206,6 @@ _thread_kern_scheduler(void) PANIC("Unable to restore alternate signal stack"); } - /* Are there pending signals for this thread? */ - if (curthread->check_pending != 0) { - curthread->check_pending = 0; - _thread_sig_check_pending(curthread); - } - /* * Enter a scheduling loop that finds the next thread that is * ready to run. This loop completes when there are no more threads @@ -335,6 +329,21 @@ _thread_kern_scheduler(void) PTHREAD_WORKQ_INSERT(curthread); break; } + + /* + * Are there pending signals for this thread? + * + * This check has to be performed after the thread + * has been placed in the queue(s) appropriate for + * its state. The process of adding pending signals + * can change a threads state, which in turn will + * attempt to add or remove the thread from any + * scheduling queue to which it belongs. + */ + if (curthread->check_pending != 0) { + curthread->check_pending = 0; + _thread_sig_check_pending(curthread); + } } /* diff --git a/lib/libpthread/thread/thr_sig.c b/lib/libpthread/thread/thr_sig.c index 71a88efe4a30..9ce53a0c702c 100644 --- a/lib/libpthread/thread/thr_sig.c +++ b/lib/libpthread/thread/thr_sig.c @@ -575,6 +575,9 @@ thread_sig_add(pthread_t pthread, int sig, int has_args) restart = _thread_sigact[sig - 1].sa_flags & SA_RESTART; + /* Make sure this signal isn't still in the pending set: */ + sigdelset(&pthread->sigpend, sig); + /* * Process according to thread state: */ -- cgit v1.3