summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-06-04 21:50:02 +0000
committerjhb <jhb@FreeBSD.org>2002-06-04 21:50:02 +0000
commit1ba6786436ce1fc3d10f82452a167a784b696702 (patch)
tree4593bdc1451cf2ce5ab477dbb5046415a5bf9661 /sys/kern/kern_mutex.c
parentd3c26c96f0316096816f849f64ee275e8ca9e627 (diff)
downloadFreeBSD-src-1ba6786436ce1fc3d10f82452a167a784b696702.zip
FreeBSD-src-1ba6786436ce1fc3d10f82452a167a784b696702.tar.gz
Add a private thread_runnable() macro to make the code more readable and
make the KSE diff easier to maintain.
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 360cb73..f9b7413 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -70,6 +70,9 @@
#define mtx_owner(m) (mtx_unowned((m)) ? NULL \
: (struct thread *)((m)->mtx_lock & MTX_FLAGMASK))
+#define thread_runnable(td) \
+ ((td)->td_kse != NULL && (td)->td_kse->ke_oncpu != NOCPU)
+
/*
* Lock classes for sleep and spin mutexes.
*/
@@ -129,7 +132,7 @@ propagate_priority(struct thread *td)
* If lock holder is actually running, just bump priority.
*/
/* XXXKSE this test is not sufficient */
- if (td->td_kse && (td->td_kse->ke_oncpu != NOCPU)) {
+ if (thread_runnable(td)) {
MPASS(td->td_proc->p_stat == SRUN
|| td->td_proc->p_stat == SZOMB
|| td->td_proc->p_stat == SSTOP);
@@ -531,8 +534,7 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
* CPU, spin instead of blocking.
*/
owner = (struct thread *)(v & MTX_FLAGMASK);
- if (m != &Giant && owner->td_kse != NULL &&
- owner->td_kse->ke_oncpu != NOCPU) {
+ if (m != &Giant && thread_runnable(owner)) {
mtx_unlock_spin(&sched_lock);
#ifdef __i386__
ia32_pause();
OpenPOWER on IntegriCloud