From 1ba6786436ce1fc3d10f82452a167a784b696702 Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 4 Jun 2002 21:50:02 +0000 Subject: Add a private thread_runnable() macro to make the code more readable and make the KSE diff easier to maintain. --- sys/kern/kern_mutex.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sys/kern/kern_mutex.c') 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(); -- cgit v1.1