diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-12-09 02:42:02 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-12-09 02:42:02 +0000 |
commit | 171976dba2208151b69025bbf1a0b5f395ddf742 (patch) | |
tree | 55786772bf8f6d419f8a02f1838bde8b593e497f /sys/kern/sched_4bsd.c | |
parent | 9eb44e2a50d42aea2650694312bacb8b83a22cc5 (diff) | |
download | FreeBSD-src-171976dba2208151b69025bbf1a0b5f395ddf742.zip FreeBSD-src-171976dba2208151b69025bbf1a0b5f395ddf742.tar.gz |
MFp4:
It is possible a lower priority thread lending priority to higher priority
thread, in old code, it is ignored, however the lending should always be
recorded, add field td_lend_user_pri to fix the problem, if a thread does
not have borrowed priority, its value is PRI_MAX.
MFC after: 1 week
Diffstat (limited to 'sys/kern/sched_4bsd.c')
-rw-r--r-- | sys/kern/sched_4bsd.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 9face64..6278126 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -879,25 +879,23 @@ sched_prio(struct thread *td, u_char prio) void sched_user_prio(struct thread *td, u_char prio) { - u_char oldprio; THREAD_LOCK_ASSERT(td, MA_OWNED); td->td_base_user_pri = prio; - if (td->td_flags & TDF_UBORROWING && td->td_user_pri <= prio) + if (td->td_lend_user_pri <= prio) return; - oldprio = td->td_user_pri; td->td_user_pri = prio; } void sched_lend_user_prio(struct thread *td, u_char prio) { - u_char oldprio; THREAD_LOCK_ASSERT(td, MA_OWNED); - td->td_flags |= TDF_UBORROWING; - oldprio = td->td_user_pri; - td->td_user_pri = prio; + if (prio < td->td_lend_user_pri) + td->td_lend_user_pri = prio; + if (prio < td->td_user_pri) + td->td_user_pri = prio; } void @@ -907,12 +905,11 @@ sched_unlend_user_prio(struct thread *td, u_char prio) THREAD_LOCK_ASSERT(td, MA_OWNED); base_pri = td->td_base_user_pri; - if (prio >= base_pri) { - td->td_flags &= ~TDF_UBORROWING; - sched_user_prio(td, base_pri); - } else { - sched_lend_user_prio(td, prio); - } + td->td_lend_user_pri = prio; + if (prio > base_pri) + td->td_user_pri = base_pri; + else + td->td_user_pri = prio; } void |