diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2007-03-21 20:46:26 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2007-03-21 20:46:26 +0000 |
| commit | 503916a7c1d38ccdfbc10aa3e2e68f95b03727c8 (patch) | |
| tree | 2204e2e98cd36759b9367d076afb477c1dd2d7eb | |
| parent | ad3f9ab320ed8ae3b99e300f7daa1469cb66139d (diff) | |
Notes
| -rw-r--r-- | sys/kern/kern_condvar.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c index e7410e63f717..62e4f04de618 100644 --- a/sys/kern/kern_condvar.c +++ b/sys/kern/kern_condvar.c @@ -96,7 +96,16 @@ void cv_wait(struct cv *cvp, struct mtx *mp) { WITNESS_SAVE_DECL(mp); + struct thread *td; + td = curthread; +#ifdef KTRACE + if (KTRPOINT(td, KTR_CSW)) + ktrcsw(1, 0); +#endif + CV_ASSERT(cvp, mp, td); + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &mp->mtx_object, + "Waiting on \"%s\"", cvp->cv_description); WITNESS_SAVE(&mp->mtx_object, mp); if (cold || panicstr) { @@ -109,7 +118,21 @@ cv_wait(struct cv *cvp, struct mtx *mp) return; } - cv_wait_unlock(cvp, mp); + sleepq_lock(cvp); + + cvp->cv_waiters++; + DROP_GIANT(); + mtx_unlock(mp); + + sleepq_add(cvp, &mp->mtx_object, cvp->cv_description, SLEEPQ_CONDVAR, + 0); + sleepq_wait(cvp); + +#ifdef KTRACE + if (KTRPOINT(td, KTR_CSW)) + ktrcsw(0, 0); +#endif + PICKUP_GIANT(); mtx_lock(mp); WITNESS_RESTORE(&mp->mtx_object, mp); } @@ -153,6 +176,10 @@ cv_wait_unlock(struct cv *cvp, struct mtx *mp) 0); sleepq_wait(cvp); +#ifdef KTRACE + if (KTRPOINT(td, KTR_CSW)) + ktrcsw(0, 0); +#endif PICKUP_GIANT(); } |
