summaryrefslogtreecommitdiff
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2003-03-04 20:32:41 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2003-03-04 20:32:41 +0000
commit5fa8dd90f9dbce57bfdac1887acedb67e19ac3b2 (patch)
tree842b508fe0eef7a8afde073a77ad4c34f18e1d8d /sys/kern/kern_mutex.c
parent6b869595c510d2dcffd8d7f0a0eb4c9b3d0ce3e9 (diff)
Notes
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index f5641c5584e9..d2d907f4dbc1 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -487,14 +487,16 @@ void
_mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
{
struct thread *td = curthread;
+ struct thread *td1;
#if defined(SMP) && defined(ADAPTIVE_MUTEXES)
struct thread *owner;
#endif
+ uintptr_t v;
#ifdef KTR
int cont_logged = 0;
#endif
- if ((m->mtx_lock & MTX_FLAGMASK) == (uintptr_t)td) {
+ if (mtx_owned(m)) {
m->mtx_recurse++;
atomic_set_ptr(&m->mtx_lock, MTX_RECURSED);
if (LOCK_LOG_TEST(&m->mtx_object, opts))
@@ -508,15 +510,15 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
m->mtx_object.lo_name, (void *)m->mtx_lock, file, line);
while (!_obtain_lock(m, td)) {
- uintptr_t v;
- struct thread *td1;
mtx_lock_spin(&sched_lock);
+ v = m->mtx_lock;
+
/*
* Check if the lock has been released while spinning for
* the sched_lock.
*/
- if ((v = m->mtx_lock) == MTX_UNOWNED) {
+ if (v == MTX_UNOWNED) {
mtx_unlock_spin(&sched_lock);
#ifdef __i386__
ia32_pause();