summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_condvar.c
diff options
context:
space:
mode:
authortanimura <tanimura@FreeBSD.org>2003-11-09 09:17:26 +0000
committertanimura <tanimura@FreeBSD.org>2003-11-09 09:17:26 +0000
commit7eade05dfa5c79c8765c89ae76635f31451fe886 (patch)
tree19de3ca43ba82c3cf15a4a6c7fba917e0f7e416b /sys/kern/kern_condvar.c
parent9cbd7fa025947081790184770a6c74511b0b0a44 (diff)
downloadFreeBSD-src-7eade05dfa5c79c8765c89ae76635f31451fe886.zip
FreeBSD-src-7eade05dfa5c79c8765c89ae76635f31451fe886.tar.gz
- Implement selwakeuppri() which allows raising the priority of a
thread being waken up. The thread waken up can run at a priority as high as after tsleep(). - Replace selwakeup()s with selwakeuppri()s and pass appropriate priorities. - Add cv_broadcastpri() which raises the priority of the broadcast threads. Used by selwakeuppri() if collision occurs. Not objected in: -arch, -current
Diffstat (limited to 'sys/kern/kern_condvar.c')
-rw-r--r--sys/kern/kern_condvar.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c
index 3344123..d95d9e2 100644
--- a/sys/kern/kern_condvar.c
+++ b/sys/kern/kern_condvar.c
@@ -525,14 +525,21 @@ cv_signal(struct cv *cvp)
* Should be called with the same mutex as was passed to cv_wait held.
*/
void
-cv_broadcast(struct cv *cvp)
+cv_broadcastpri(struct cv *cvp, int pri)
{
+ struct thread *td;
KASSERT(cvp != NULL, ("%s: cvp NULL", __func__));
mtx_lock_spin(&sched_lock);
CV_SIGNAL_VALIDATE(cvp);
- while (!TAILQ_EMPTY(&cvp->cv_waitq))
+ while (!TAILQ_EMPTY(&cvp->cv_waitq)) {
+ if (pri >= PRI_MIN && pri <= PRI_MAX) {
+ td = TAILQ_FIRST(&cvp->cv_waitq);
+ if (td->td_priority > pri)
+ td->td_priority = pri;
+ }
cv_wakeup(cvp);
+ }
mtx_unlock_spin(&sched_lock);
}
OpenPOWER on IntegriCloud