summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_umtx.c
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2004-03-27 14:32:03 +0000
committermtm <mtm@FreeBSD.org>2004-03-27 14:32:03 +0000
commit873aa62c96819be1a7ca81e440c7935d0e614ecd (patch)
treee65a57e2de018ef0da7c7bcccc6e17fefd14f12d /sys/kern/kern_umtx.c
parentadb111ed69292eafc661e12b3c5d2f896c4ed0f4 (diff)
downloadFreeBSD-src-873aa62c96819be1a7ca81e440c7935d0e614ecd.zip
FreeBSD-src-873aa62c96819be1a7ca81e440c7935d0e614ecd.tar.gz
Use the proc lock to sleep on a libthr umtx.
Diffstat (limited to 'sys/kern/kern_umtx.c')
-rw-r--r--sys/kern/kern_umtx.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index cbd2e5a..e767ec8 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -214,18 +214,20 @@ _umtx_lock(struct thread *td, struct _umtx_lock_args *uap)
* and we need to retry or we lost a race to the thread
* unlocking the umtx.
*/
- UMTX_LOCK();
+ PROC_LOCK(td->td_proc);
mtx_lock_spin(&sched_lock);
if (old == owner && (td->td_flags & TDF_UMTXWAKEUP) == 0) {
mtx_unlock_spin(&sched_lock);
- error = msleep(td, &umtx_lock,
+ error = msleep(td, &td->td_proc->p_mtx,
td->td_priority | PCATCH, "umtx", 0);
mtx_lock_spin(&sched_lock);
} else
error = 0;
td->td_flags &= ~TDF_UMTXWAKEUP;
mtx_unlock_spin(&sched_lock);
+ PROC_UNLOCK(td->td_proc);
+ UMTX_LOCK();
umtx_remove(uq, td);
UMTX_UNLOCK();
@@ -317,9 +319,11 @@ _umtx_unlock(struct thread *td, struct _umtx_unlock_args *uap)
* If there is a thread waiting on the umtx, wake it up.
*/
if (blocked != NULL) {
+ PROC_LOCK(blocked->td_proc);
mtx_lock_spin(&sched_lock);
blocked->td_flags |= TDF_UMTXWAKEUP;
mtx_unlock_spin(&sched_lock);
+ PROC_UNLOCK(blocked->td_proc);
wakeup(blocked);
}
OpenPOWER on IntegriCloud