diff options
author | jhb <jhb@FreeBSD.org> | 2002-06-04 21:50:02 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2002-06-04 21:50:02 +0000 |
commit | 1ba6786436ce1fc3d10f82452a167a784b696702 (patch) | |
tree | 4593bdc1451cf2ce5ab477dbb5046415a5bf9661 /sys | |
parent | d3c26c96f0316096816f849f64ee275e8ca9e627 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/kern/kern_mutex.c | 8 | ||||
-rw-r--r-- | sys/kern/subr_turnstile.c | 8 |
2 files changed, 10 insertions, 6 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(); diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c index 360cb73..f9b7413 100644 --- a/sys/kern/subr_turnstile.c +++ b/sys/kern/subr_turnstile.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(); |