diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-06-01 10:21:27 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-06-01 10:21:27 +0000 |
commit | b2d8833118285ea2aadaf3bb919bb94641161542 (patch) | |
tree | 0dfbd61266cb930029594be99dcde49b536dd840 /sys/kern | |
parent | 8b3225317ab54125c7fb4f2be400ed14dade138a (diff) |
Change wakeup_proc() to no longer grab the SCHED_LOCK() instead it must
be called with SCHED_LOCK() held. Also add an extra argument to update
the process flags p_flag so that the timeout handler can set the
P_TIMEOUT flag before making the process runnable.
OK mpi@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_synch.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index fd97013cb26..8165d2f27b8 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.191 2023/02/15 20:43:41 mvs Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.192 2023/06/01 10:21:26 claudio Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -470,20 +470,22 @@ sleep_signal_check(void) } int -wakeup_proc(struct proc *p, const volatile void *chan) +wakeup_proc(struct proc *p, const volatile void *chan, int flags) { - int s, awakened = 0; + int awakened = 0; + + SCHED_ASSERT_LOCKED(); - SCHED_LOCK(s); if (p->p_wchan != NULL && ((chan == NULL) || (p->p_wchan == chan))) { awakened = 1; + if (flags) + atomic_setbits_int(&p->p_flag, flags); if (p->p_stat == SSLEEP) setrunnable(p); else unsleep(p); } - SCHED_UNLOCK(s); return awakened; } @@ -502,8 +504,7 @@ endtsleep(void *arg) int s; SCHED_LOCK(s); - if (wakeup_proc(p, NULL)) - atomic_setbits_int(&p->p_flag, P_TIMEOUT); + wakeup_proc(p, NULL, P_TIMEOUT); SCHED_UNLOCK(s); } @@ -548,7 +549,7 @@ wakeup_n(const volatile void *ident, int n) if (p->p_stat != SSLEEP && p->p_stat != SSTOP) panic("wakeup: p_stat is %d", (int)p->p_stat); #endif - if (wakeup_proc(p, ident)) + if (wakeup_proc(p, ident, 0)) --n; } SCHED_UNLOCK(s); |