aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authorJulian Elischer <julian@FreeBSD.org>2002-08-01 18:45:10 +0000
committerJulian Elischer <julian@FreeBSD.org>2002-08-01 18:45:10 +0000
commit04774f2357e4c0f879cc50b2e17ba445108a0a7a (patch)
tree8a197b12a5345ddab4947db75c41005118cfc2c2 /sys/kern/kern_sig.c
parentee0812f32049d2a8cc09699598db1f4c7276f4d4 (diff)
downloadsrc-04774f2357e4c0f879cc50b2e17ba445108a0a7a.tar.gz
src-04774f2357e4c0f879cc50b2e17ba445108a0a7a.zip
Slight cleanup of some comments/whitespace.
Make idle process state more consistant. Add an assert on thread state. Clean up idleproc/mi_switch() interaction. Use a local instead of referencing curthread 7 times in a row (I've been told curthread can be expensive on some architectures) Remove some commented out code. Add a little commented out code (completion coming soon) Reviewed by: jhb@freebsd.org
Notes
Notes: svn path=/head/; revision=101176
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 2c39e13c1b49..87711abe1a5b 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1364,7 +1364,7 @@ psignal(p, sig)
* The signal is not ignored or caught.
*/
mtx_lock_spin(&sched_lock);
- thread_unsuspend(p); /* Checks if should do it. */
+ thread_unsuspend(p);
mtx_unlock_spin(&sched_lock);
goto out;
}
@@ -1373,7 +1373,9 @@ psignal(p, sig)
/*
* Already stopped, don't need to stop again
* (If we did the shell could get confused).
+ * Just make sure the signal STOP bit set.
*/
+ p->p_flag |= P_STOPPED_SGNL;
SIGDELSET(p->p_siglist, sig);
goto out;
}
@@ -1383,10 +1385,8 @@ psignal(p, sig)
* If a thread is sleeping interruptibly, simulate a
* wakeup so that when it is continued it will be made
* runnable and can look at the signal. However, don't make
- * the process runnable, leave it stopped.
+ * the PROCESS runnable, leave it stopped.
* It may run a bit until it hits a thread_suspend_check().
- *
- * XXXKSE I don't understand this at all.
*/
mtx_lock_spin(&sched_lock);
FOREACH_THREAD_IN_PROC(p, td) {
@@ -1403,6 +1403,8 @@ psignal(p, sig)
/*
* XXXKSE What about threads that are waiting on mutexes?
* Shouldn't they abort too?
+ * No, hopefully mutexes are short lived.. They'll
+ * eventually hit thread_suspend_check().
*/
} else if (p->p_state == PRS_NORMAL) {
if (prop & SA_CONT) {
@@ -1419,6 +1421,7 @@ psignal(p, sig)
* cause the process to run.
*/
if (prop & SA_STOP) {
+ int should_signal = 1;
if (action != SIG_DFL)
goto runfast;
@@ -1430,8 +1433,22 @@ psignal(p, sig)
goto out;
SIGDELSET(p->p_siglist, sig);
p->p_xstat = sig;
- PROC_LOCK(p->p_pptr);
- if (!(p->p_pptr->p_procsig->ps_flag & PS_NOCLDSTOP))
+ PROC_LOCK(p->p_pptr); /* XXX un-needed? */
+#if 0
+ FOREACH_THREAD_IN_PROC(p, td) {
+ if (td->td_state == TDS_RUNNING) {
+ /*
+ * all other states must be in
+ * the kernel
+ */
+ should_signal = 0;
+ break;
+ }
+ }
+/* don't enable until the equivalent code is in thread_suspend_check() */
+#endif
+ if (!(p->p_pptr->p_procsig->ps_flag & PS_NOCLDSTOP) &&
+ should_signal)
psignal(p->p_pptr, SIGCHLD);
PROC_UNLOCK(p->p_pptr);
stop(p);