diff options
author | tanimura <tanimura@FreeBSD.org> | 2003-11-09 09:17:26 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2003-11-09 09:17:26 +0000 |
commit | 7eade05dfa5c79c8765c89ae76635f31451fe886 (patch) | |
tree | 19de3ca43ba82c3cf15a4a6c7fba917e0f7e416b /sys/kern/sys_generic.c | |
parent | 9cbd7fa025947081790184770a6c74511b0b0a44 (diff) | |
download | FreeBSD-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/sys_generic.c')
-rw-r--r-- | sys/kern/sys_generic.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 221ec00..881be56 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -82,6 +82,7 @@ static int dofileread(struct thread *, struct file *, int, void *, size_t, off_t, int); static int dofilewrite(struct thread *, struct file *, int, const void *, size_t, off_t, int); +static void doselwakeup(struct selinfo *, int); /* * Read system call. @@ -1162,12 +1163,30 @@ selrecord(selector, sip) mtx_unlock(&sellock); } +/* Wake up a selecting thread. */ +void +selwakeup(sip) + struct selinfo *sip; +{ + doselwakeup(sip, -1); +} + +/* Wake up a selecting thread, and set its priority. */ +void +selwakeuppri(sip, pri) + struct selinfo *sip; + int pri; +{ + doselwakeup(sip, pri); +} + /* * Do a wakeup when a selectable event occurs. */ -void -selwakeup(sip) +static void +doselwakeup(sip, pri) struct selinfo *sip; + int pri; { struct thread *td; @@ -1176,7 +1195,7 @@ selwakeup(sip) if ((sip->si_flags & SI_COLL) != 0) { nselcoll++; sip->si_flags &= ~SI_COLL; - cv_broadcast(&selwait); + cv_broadcastpri(&selwait, pri); } if (td == NULL) { mtx_unlock(&sellock); @@ -1188,6 +1207,8 @@ selwakeup(sip) if (td->td_wchan == &selwait) { cv_waitq_remove(td); TD_CLR_SLEEPING(td); + if (pri >= PRI_MIN && pri <= PRI_MAX && td->td_priority > pri) + td->td_priority = pri; setrunnable(td); } else td->td_flags &= ~TDF_SELECT; |