diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index d1b5d3fbc257..856e2dc18cd6 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -280,13 +280,10 @@ thr_suspend(struct thread *td, struct thr_suspend_args *uap) hz = tvtohz(&tv); } PROC_LOCK(td->td_proc); - mtx_lock_spin(&sched_lock); - if ((td->td_flags & TDF_THRWAKEUP) == 0) { - mtx_unlock_spin(&sched_lock); + if ((td->td_flags & TDF_THRWAKEUP) == 0) error = msleep((void *)td, &td->td_proc->p_mtx, td->td_priority | PCATCH, "lthr", hz); - mtx_lock_spin(&sched_lock); - } + mtx_lock_spin(&sched_lock); td->td_flags &= ~TDF_THRWAKEUP; mtx_unlock_spin(&sched_lock); PROC_UNLOCK(td->td_proc); diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index e1ae68d0490e..1289cd744fb0 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -217,14 +217,12 @@ _umtx_lock(struct thread *td, struct _umtx_lock_args *uap) * unlocking the umtx. */ PROC_LOCK(td->td_proc); - mtx_lock_spin(&sched_lock); - if (old == owner && (td->td_flags & TDF_UMTXWAKEUP) == 0) { - mtx_unlock_spin(&sched_lock); + if (old == owner && (td->td_flags & TDF_UMTXWAKEUP) == 0) error = msleep(td, &td->td_proc->p_mtx, td->td_priority | PCATCH, "umtx", 0); - mtx_lock_spin(&sched_lock); - } else + else error = 0; + mtx_lock_spin(&sched_lock); td->td_flags &= ~TDF_UMTXWAKEUP; mtx_unlock_spin(&sched_lock); PROC_UNLOCK(td->td_proc);