diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-11-03 22:52:09 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-11-03 22:52:09 +0000 |
commit | 86a87028996004a6089446b221e294e958ea0175 (patch) | |
tree | b53cfba66b965a69ff87fba9ffb64e8fa670af38 /sys | |
parent | d95171e62eb71980350204462dbb3fbab29f435c (diff) |
Need to call unsleep before doing the SSTOP check. We need to ensure that
if a sleep is interrupted but the thread is also stopped that on a wakeup
the thread runs again.
OK mpi@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_synch.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 2faac3bed23..c7aed90b9f4 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.208 2024/11/01 09:30:12 claudio Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.209 2024/11/03 22:52:08 claudio Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -393,23 +393,29 @@ sleep_finish(int timo, int do_sleep) SCHED_LOCK(); /* - * If the wakeup happens while going to sleep, p->p_wchan + * A few checks need to happen before going to sleep: + * - If the wakeup happens while going to sleep, p->p_wchan * will be NULL. In that case unwind immediately but still * check for possible signals and timeouts. + * - If the sleep is aborted call unsleep and take us of the + * sleep queue. + * - If requested to stop force a switch even if the sleep + * condition got cleared. */ if (p->p_wchan == NULL) do_sleep = 0; + if (do_sleep == 0) + unsleep(p); + if (p->p_stat == SSTOP) + do_sleep = 1; atomic_clearbits_int(&p->p_flag, P_WSLEEP); - if (p->p_stat == SSTOP) /* force sleep if process is stopped */ - do_sleep = 1; if (do_sleep) { KASSERT(p->p_stat == SSLEEP || p->p_stat == SSTOP); p->p_ru.ru_nvcsw++; mi_switch(); } else { KASSERT(p->p_stat == SONPROC || p->p_stat == SSLEEP); - unsleep(p); p->p_stat = SONPROC; } |