| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_lwp.c,v 1.190 2017/06/22 09:05:09 skrll Exp $ */ | | 1 | /* $NetBSD: kern_lwp.c,v 1.191 2017/12/02 22:51:22 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Nathan J. Williams, and Andrew Doran. | | 8 | * by Nathan J. Williams, and Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -201,27 +201,27 @@ | | | @@ -201,27 +201,27 @@ |
201 | * (But not always for kernel threads. There are some special cases | | 201 | * (But not always for kernel threads. There are some special cases |
202 | * as mentioned above. See kern_softint.c.) | | 202 | * as mentioned above. See kern_softint.c.) |
203 | * | | 203 | * |
204 | * Note that an LWP is considered running or likely to run soon if in | | 204 | * Note that an LWP is considered running or likely to run soon if in |
205 | * one of the following states. This affects the value of p_nrlwps: | | 205 | * one of the following states. This affects the value of p_nrlwps: |
206 | * | | 206 | * |
207 | * LSRUN, LSONPROC, LSSLEEP | | 207 | * LSRUN, LSONPROC, LSSLEEP |
208 | * | | 208 | * |
209 | * p_lock does not need to be held when transitioning among these | | 209 | * p_lock does not need to be held when transitioning among these |
210 | * three states, hence p_lock is rarely taken for state transitions. | | 210 | * three states, hence p_lock is rarely taken for state transitions. |
211 | */ | | 211 | */ |
212 | | | 212 | |
213 | #include <sys/cdefs.h> | | 213 | #include <sys/cdefs.h> |
214 | __KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.190 2017/06/22 09:05:09 skrll Exp $"); | | 214 | __KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.191 2017/12/02 22:51:22 christos Exp $"); |
215 | | | 215 | |
216 | #include "opt_ddb.h" | | 216 | #include "opt_ddb.h" |
217 | #include "opt_lockdebug.h" | | 217 | #include "opt_lockdebug.h" |
218 | #include "opt_dtrace.h" | | 218 | #include "opt_dtrace.h" |
219 | | | 219 | |
220 | #define _LWP_API_PRIVATE | | 220 | #define _LWP_API_PRIVATE |
221 | | | 221 | |
222 | #include <sys/param.h> | | 222 | #include <sys/param.h> |
223 | #include <sys/systm.h> | | 223 | #include <sys/systm.h> |
224 | #include <sys/cpu.h> | | 224 | #include <sys/cpu.h> |
225 | #include <sys/pool.h> | | 225 | #include <sys/pool.h> |
226 | #include <sys/proc.h> | | 226 | #include <sys/proc.h> |
227 | #include <sys/syscallargs.h> | | 227 | #include <sys/syscallargs.h> |
| @@ -635,28 +635,29 @@ lwp_wait(struct lwp *l, lwpid_t lid, lwp | | | @@ -635,28 +635,29 @@ lwp_wait(struct lwp *l, lwpid_t lid, lwp |
635 | if (error != 0) | | 635 | if (error != 0) |
636 | break; | | 636 | break; |
637 | if (nfound == 0) { | | 637 | if (nfound == 0) { |
638 | error = ESRCH; | | 638 | error = ESRCH; |
639 | break; | | 639 | break; |
640 | } | | 640 | } |
641 | | | 641 | |
642 | /* | | 642 | /* |
643 | * Note: since the lock will be dropped, need to restart on | | 643 | * Note: since the lock will be dropped, need to restart on |
644 | * wakeup to run all LWPs again, e.g. there may be new LWPs. | | 644 | * wakeup to run all LWPs again, e.g. there may be new LWPs. |
645 | */ | | 645 | */ |
646 | if (exiting) { | | 646 | if (exiting) { |
647 | KASSERT(p->p_nlwps > 1); | | 647 | KASSERT(p->p_nlwps > 1); |
648 | cv_wait(&p->p_lwpcv, p->p_lock); | | 648 | error = cv_wait_sig(&p->p_lwpcv, p->p_lock); |
649 | error = EAGAIN; | | 649 | if (error == 0) |
| | | 650 | error = EAGAIN; |
650 | break; | | 651 | break; |
651 | } | | 652 | } |
652 | | | 653 | |
653 | /* | | 654 | /* |
654 | * If all other LWPs are waiting for exits or suspends | | 655 | * If all other LWPs are waiting for exits or suspends |
655 | * and the supply of zombies and potential zombies is | | 656 | * and the supply of zombies and potential zombies is |
656 | * exhausted, then we are about to deadlock. | | 657 | * exhausted, then we are about to deadlock. |
657 | * | | 658 | * |
658 | * If the process is exiting (and this LWP is not the one | | 659 | * If the process is exiting (and this LWP is not the one |
659 | * that is coordinating the exit) then bail out now. | | 660 | * that is coordinating the exit) then bail out now. |
660 | */ | | 661 | */ |
661 | if ((p->p_sflag & PS_WEXIT) != 0 || | | 662 | if ((p->p_sflag & PS_WEXIT) != 0 || |
662 | p->p_nrlwps + p->p_nzlwps - p->p_ndlwps <= p->p_nlwpwait) { | | 663 | p->p_nrlwps + p->p_nzlwps - p->p_ndlwps <= p->p_nlwpwait) { |