summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_thr.c
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2004-12-01 13:50:04 +0000
committerdavidxu <davidxu@FreeBSD.org>2004-12-01 13:50:04 +0000
commit44dde891d6bbef4f36952ff9c2024c691186daac (patch)
tree7a604f36cfd12f8d97a6862d7a5084f3c78adab0 /sys/kern/kern_thr.c
parent05b9cb2a46b4cd19b0e7335c469c484f6f83c3e6 (diff)
downloadFreeBSD-src-44dde891d6bbef4f36952ff9c2024c691186daac.zip
FreeBSD-src-44dde891d6bbef4f36952ff9c2024c691186daac.tar.gz
If a thread is resumed by thr_wake, it should return 0, especially it
should not return ERESTART after it caught a signal, otherwise thr_wake() call will be lost, also a timeout wait should not be restarted. Final, using wakeup not wakeup_one to be safeness.
Diffstat (limited to 'sys/kern/kern_thr.c')
-rw-r--r--sys/kern/kern_thr.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c
index baa9224..7b16c94 100644
--- a/sys/kern/kern_thr.c
+++ b/sys/kern/kern_thr.c
@@ -264,11 +264,21 @@ thr_suspend(struct thread *td, struct thr_suspend_args *uap)
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);
- td->td_flags &= ~TDF_THRWAKEUP;
- mtx_unlock_spin(&sched_lock);
+ if (td->td_flags & TDF_THRWAKEUP) {
+ mtx_lock_spin(&sched_lock);
+ td->td_flags &= ~TDF_THRWAKEUP;
+ mtx_unlock_spin(&sched_lock);
+ PROC_UNLOCK(td->td_proc);
+ return (0);
+ }
PROC_UNLOCK(td->td_proc);
- return (error == EWOULDBLOCK ? ETIMEDOUT : error);
+ if (error == EWOULDBLOCK)
+ error = ETIMEDOUT;
+ else if (error == ERESTART) {
+ if (hz != 0)
+ error = EINTR;
+ }
+ return (error);
}
int
@@ -289,7 +299,7 @@ thr_wake(struct thread *td, struct thr_wake_args *uap)
mtx_lock_spin(&sched_lock);
ttd->td_flags |= TDF_THRWAKEUP;
mtx_unlock_spin(&sched_lock);
- wakeup_one((void *)ttd);
+ wakeup((void *)ttd);
PROC_UNLOCK(td->td_proc);
return (0);
}
OpenPOWER on IntegriCloud