Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern In sa_yield(), sleep on a p->p_sa->sa_idle instead ...



details:   https://anonhg.NetBSD.org/src/rev/18f90b7eabf6
branches:  trunk
changeset: 542657:18f90b7eabf6
user:      nathanw <nathanw%NetBSD.org@localhost>
date:      Mon Feb 03 23:31:42 2003 +0000

description:
In sa_yield(), sleep on a p->p_sa->sa_idle instead of just p, to avoid
being woken up by the the reaper when a child process is cleaned up
(SIGCHLD will still cause this to run, and threads actually waiting
for the child will still see the wakeup, of course).

Should fix various spurious wakeups that manifest as assertion
failures in pthread__idle().

diffstat:

 sys/kern/kern_sa.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (47 lines):

diff -r 495256715d9e -r 18f90b7eabf6 sys/kern/kern_sa.c
--- a/sys/kern/kern_sa.c        Mon Feb 03 23:16:30 2003 +0000
+++ b/sys/kern/kern_sa.c        Mon Feb 03 23:31:42 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sa.c,v 1.4 2003/02/01 06:23:43 thorpej Exp $      */
+/*     $NetBSD: kern_sa.c,v 1.5 2003/02/03 23:31:42 nathanw Exp $      */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.4 2003/02/01 06:23:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.5 2003/02/03 23:31:42 nathanw Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -278,9 +278,7 @@
        struct proc *p = l->l_proc;
        struct sadata *sa = p->p_sa;
        int s;
-
-       DPRINTFN(1,("sa_yield(%d.%d)\n", p->p_pid, l->l_lid));
-
+       
        /*
         * If we're the last running LWP, stick around to recieve
         * signals.
@@ -303,13 +301,16 @@
                if (p->p_userret == NULL) {
                        sa->sa_idle = l;
                        l->l_flag &= ~L_SA;
-                       tsleep((caddr_t) p, PUSER | PCATCH, "sawait", 0);
+                       tsleep((caddr_t) sa->sa_idle, PUSER | PCATCH,
+                           "sawait", 0);
                        l->l_flag |= L_SA;
                        sa->sa_idle = NULL;
                        sa->sa_vp = l;
                }
                splx(s);
        } else {
+               DPRINTFN(1,("sa_yield(%d.%d) stepping aside\n", p->p_pid, l->l_lid));
+       
                SCHED_LOCK(s);
                l2 = sa->sa_woken;
                sa->sa_woken = NULL;



Home | Main Index | Thread Index | Old Index