| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_synch.c,v 1.308 2014/02/28 10:16:51 skrll Exp $ */ | | 1 | /* $NetBSD: kern_synch.c,v 1.309 2015/10/13 00:25:51 pgoyette Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009 | | 4 | * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009 |
5 | * The NetBSD Foundation, Inc. | | 5 | * The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 9 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
10 | * NASA Ames Research Center, by Charles M. Hannum, Andrew Doran and | | 10 | * NASA Ames Research Center, by Charles M. Hannum, Andrew Doran and |
11 | * Daniel Sieger. | | 11 | * Daniel Sieger. |
12 | * | | 12 | * |
13 | * Redistribution and use in source and binary forms, with or without | | 13 | * Redistribution and use in source and binary forms, with or without |
14 | * modification, are permitted provided that the following conditions | | 14 | * modification, are permitted provided that the following conditions |
| @@ -59,27 +59,27 @@ | | | @@ -59,27 +59,27 @@ |
59 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 59 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
60 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 60 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
61 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 61 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
62 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 62 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
63 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 63 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
64 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 64 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
65 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 65 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
66 | * SUCH DAMAGE. | | 66 | * SUCH DAMAGE. |
67 | * | | 67 | * |
68 | * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 | | 68 | * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 |
69 | */ | | 69 | */ |
70 | | | 70 | |
71 | #include <sys/cdefs.h> | | 71 | #include <sys/cdefs.h> |
72 | __KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.308 2014/02/28 10:16:51 skrll Exp $"); | | 72 | __KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.309 2015/10/13 00:25:51 pgoyette Exp $"); |
73 | | | 73 | |
74 | #include "opt_kstack.h" | | 74 | #include "opt_kstack.h" |
75 | #include "opt_perfctrs.h" | | 75 | #include "opt_perfctrs.h" |
76 | #include "opt_dtrace.h" | | 76 | #include "opt_dtrace.h" |
77 | | | 77 | |
78 | #define __MUTEX_PRIVATE | | 78 | #define __MUTEX_PRIVATE |
79 | | | 79 | |
80 | #include <sys/param.h> | | 80 | #include <sys/param.h> |
81 | #include <sys/systm.h> | | 81 | #include <sys/systm.h> |
82 | #include <sys/proc.h> | | 82 | #include <sys/proc.h> |
83 | #include <sys/kernel.h> | | 83 | #include <sys/kernel.h> |
84 | #if defined(PERFCTRS) | | 84 | #if defined(PERFCTRS) |
85 | #include <sys/pmc.h> | | 85 | #include <sys/pmc.h> |
| @@ -975,27 +975,33 @@ suspendsched(void) | | | @@ -975,27 +975,33 @@ suspendsched(void) |
975 | struct proc *p; | | 975 | struct proc *p; |
976 | | | 976 | |
977 | /* | | 977 | /* |
978 | * We do this by process in order not to violate the locking rules. | | 978 | * We do this by process in order not to violate the locking rules. |
979 | */ | | 979 | */ |
980 | mutex_enter(proc_lock); | | 980 | mutex_enter(proc_lock); |
981 | PROCLIST_FOREACH(p, &allproc) { | | 981 | PROCLIST_FOREACH(p, &allproc) { |
982 | mutex_enter(p->p_lock); | | 982 | mutex_enter(p->p_lock); |
983 | if ((p->p_flag & PK_SYSTEM) != 0) { | | 983 | if ((p->p_flag & PK_SYSTEM) != 0) { |
984 | mutex_exit(p->p_lock); | | 984 | mutex_exit(p->p_lock); |
985 | continue; | | 985 | continue; |
986 | } | | 986 | } |
987 | | | 987 | |
988 | p->p_stat = SSTOP; | | 988 | if (p->p_stat != SSTOP) { |
| | | 989 | if (p->p_stat != SZOMB && p->p_stat != SDEAD) { |
| | | 990 | p->p_pptr->p_nstopchild++; |
| | | 991 | p->p_waited = 0; |
| | | 992 | } |
| | | 993 | p->p_stat = SSTOP; |
| | | 994 | } |
989 | | | 995 | |
990 | LIST_FOREACH(l, &p->p_lwps, l_sibling) { | | 996 | LIST_FOREACH(l, &p->p_lwps, l_sibling) { |
991 | if (l == curlwp) | | 997 | if (l == curlwp) |
992 | continue; | | 998 | continue; |
993 | | | 999 | |
994 | lwp_lock(l); | | 1000 | lwp_lock(l); |
995 | | | 1001 | |
996 | /* | | 1002 | /* |
997 | * Set L_WREBOOT so that the LWP will suspend itself | | 1003 | * Set L_WREBOOT so that the LWP will suspend itself |
998 | * when it tries to return to user mode. We want to | | 1004 | * when it tries to return to user mode. We want to |
999 | * try and get to get as many LWPs as possible to | | 1005 | * try and get to get as many LWPs as possible to |
1000 | * the user / kernel boundary, so that they will | | 1006 | * the user / kernel boundary, so that they will |
1001 | * release any locks that they hold. | | 1007 | * release any locks that they hold. |