version 1.55.2.10, 2007/03/24 17:13:14 |
version 1.55.2.11, 2007/04/16 23:31:20 |
Line 862 lwp_free(struct lwp *l, bool recycle, bo |
|
Line 862 lwp_free(struct lwp *l, bool recycle, bo |
|
*/ |
*/ |
if (l->l_cpu->ci_curlwp == l) { |
if (l->l_cpu->ci_curlwp == l) { |
int count; |
int count; |
|
(void)count; /* XXXgcc */ |
KERNEL_UNLOCK_ALL(curlwp, &count); |
KERNEL_UNLOCK_ALL(curlwp, &count); |
while (l->l_cpu->ci_curlwp == l) |
while (l->l_cpu->ci_curlwp == l) |
SPINLOCK_BACKOFF_HOOK; |
SPINLOCK_BACKOFF_HOOK; |
Line 1080 lwp_locked(struct lwp *l, kmutex_t *mtx) |
|
Line 1081 lwp_locked(struct lwp *l, kmutex_t *mtx) |
|
{ |
{ |
kmutex_t *cur = l->l_mutex; |
kmutex_t *cur = l->l_mutex; |
|
|
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
return mutex_owned(cur) && (mtx == cur || mtx == NULL); |
return mutex_owned(cur) && (mtx == cur || mtx == NULL); |
#else |
|
return mutex_owned(cur); |
|
#endif |
|
} |
} |
|
|
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
/* |
/* |
* Lock an LWP. |
* Lock an LWP. |
*/ |
*/ |
Line 1119 lwp_lock_retry(struct lwp *l, kmutex_t * |
|
Line 1115 lwp_lock_retry(struct lwp *l, kmutex_t * |
|
} while (__predict_false(l->l_mutex != old)); |
} while (__predict_false(l->l_mutex != old)); |
#endif |
#endif |
} |
} |
#endif |
|
|
|
/* |
/* |
* Lend a new mutex to an LWP. The old mutex must be held. |
* Lend a new mutex to an LWP. The old mutex must be held. |
Line 1130 lwp_setlock(struct lwp *l, kmutex_t *new |
|
Line 1125 lwp_setlock(struct lwp *l, kmutex_t *new |
|
|
|
KASSERT(mutex_owned(l->l_mutex)); |
KASSERT(mutex_owned(l->l_mutex)); |
|
|
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
mb_write(); |
mb_write(); |
l->l_mutex = new; |
l->l_mutex = new; |
#else |
|
(void)new; |
|
#endif |
|
} |
} |
|
|
/* |
/* |
Line 1150 lwp_unlock_to(struct lwp *l, kmutex_t *n |
|
Line 1141 lwp_unlock_to(struct lwp *l, kmutex_t *n |
|
KASSERT(mutex_owned(l->l_mutex)); |
KASSERT(mutex_owned(l->l_mutex)); |
|
|
old = l->l_mutex; |
old = l->l_mutex; |
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
mb_write(); |
mb_write(); |
l->l_mutex = new; |
l->l_mutex = new; |
#else |
|
(void)new; |
|
#endif |
|
mutex_spin_exit(old); |
mutex_spin_exit(old); |
} |
} |
|
|
Line 1166 lwp_unlock_to(struct lwp *l, kmutex_t *n |
|
Line 1153 lwp_unlock_to(struct lwp *l, kmutex_t *n |
|
void |
void |
lwp_relock(struct lwp *l, kmutex_t *new) |
lwp_relock(struct lwp *l, kmutex_t *new) |
{ |
{ |
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
kmutex_t *old; |
kmutex_t *old; |
#endif |
|
|
|
KASSERT(mutex_owned(l->l_mutex)); |
KASSERT(mutex_owned(l->l_mutex)); |
|
|
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
old = l->l_mutex; |
old = l->l_mutex; |
if (old != new) { |
if (old != new) { |
mutex_spin_enter(new); |
mutex_spin_enter(new); |
l->l_mutex = new; |
l->l_mutex = new; |
mutex_spin_exit(old); |
mutex_spin_exit(old); |
} |
} |
#else |
|
(void)new; |
|
#endif |
|
} |
} |
|
|
int |
int |
lwp_trylock(struct lwp *l) |
lwp_trylock(struct lwp *l) |
{ |
{ |
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
kmutex_t *old; |
kmutex_t *old; |
|
|
for (;;) { |
for (;;) { |
Line 1197 lwp_trylock(struct lwp *l) |
|
Line 1177 lwp_trylock(struct lwp *l) |
|
return 1; |
return 1; |
mutex_spin_exit(old); |
mutex_spin_exit(old); |
} |
} |
#else |
|
return mutex_tryenter(l->l_mutex); |
|
#endif |
|
} |
} |
|
|
/* |
/* |