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 | |
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')
52 files changed, 105 insertions, 74 deletions
diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c index d9cfdc3..749447f 100644 --- a/sys/cam/scsi/scsi_target.c +++ b/sys/cam/scsi/scsi_target.c @@ -1119,7 +1119,7 @@ notify_user(struct targ_softc *softc) * Notify users sleeping via poll(), kqueue(), and * blocking read(). */ - selwakeup(&softc->read_select); + selwakeuppri(&softc->read_select, PRIBIO); KNOTE(&softc->read_select.si_note, 0); wakeup(&softc->user_ccb_queue); } diff --git a/sys/coda/coda_psdev.c b/sys/coda/coda_psdev.c index debbdbf..133d0fd 100644 --- a/sys/coda/coda_psdev.c +++ b/sys/coda/coda_psdev.c @@ -526,7 +526,7 @@ coda_call(mntinfo, inSize, outSize, buffer) /* Append msg to request queue and poke Venus. */ INSQUE(vmp->vm_chain, vcp->vc_requests); - selwakeup(&(vcp->vc_selproc)); + selwakeuppri(&(vcp->vc_selproc), coda_call_sleep); /* We can be interrupted while we wait for Venus to process * our request. If the interrupt occurs before Venus has read @@ -664,7 +664,7 @@ coda_call(mntinfo, inSize, outSize, buffer) /* insert at head of queue! */ INSQUE(svmp->vm_chain, vcp->vc_requests); - selwakeup(&(vcp->vc_selproc)); + selwakeuppri(&(vcp->vc_selproc), coda_call_sleep); } } diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c index 8466bd8..bb54691 100644 --- a/sys/dev/aac/aac.c +++ b/sys/dev/aac/aac.c @@ -2717,7 +2717,7 @@ aac_handle_aif(struct aac_softc *sc, struct aac_fib *fib) if (sc->aac_state & AAC_STATE_AIF_SLEEPER) wakeup(sc->aac_aifq); /* Wakeup any poll()ers */ - selwakeup(&sc->rcv_select); + selwakeuppri(&sc->rcv_select, PRIBIO); } AAC_LOCK_RELEASE(&sc->aac_aifq_lock); diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index ef98da4..2c14bbe 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/psm.c @@ -2371,7 +2371,7 @@ psmintr(void *arg) sc->state &= ~PSM_ASLP; wakeup( sc); } - selwakeup(&sc->rsel); + selwakeuppri(&sc->rsel, PZERO); } } diff --git a/sys/dev/bktr/bktr_core.c b/sys/dev/bktr/bktr_core.c index 19795a2..b9d21b8 100644 --- a/sys/dev/bktr/bktr_core.c +++ b/sys/dev/bktr/bktr_core.c @@ -821,7 +821,7 @@ common_bktr_intr( void *arg ) /* If someone has a select() on /dev/vbi, inform them */ if (SEL_WAITING(&bktr->vbi_select)) { - selwakeup(&bktr->vbi_select); + selwakeuppri(&bktr->vbi_select, VBIPRI); } diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c index be01cc4..9844e7b 100644 --- a/sys/dev/firewire/firewire.c +++ b/sys/dev/firewire/firewire.c @@ -1963,7 +1963,7 @@ fw_rcv(struct fw_rcv_buf *rb) #else if (&xferq->rsel.si_pid != 0) #endif - selwakeup(&xferq->rsel); + selwakeuppri(&xferq->rsel, FWPRI); if (xferq->flag & FWXFERQ_WAKEUP) { xferq->flag &= ~FWXFERQ_WAKEUP; wakeup((caddr_t)xferq); diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index 1e8785d..f5dd583 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -676,7 +676,7 @@ genkbd_event(keyboard_t *kbd, int event, void *arg) sc->gkb_flags &= ~KB_ASLEEP; wakeup(sc); } - selwakeup(&sc->gkb_rsel); + selwakeuppri(&sc->gkb_rsel, PZERO); return 0; default: return EINVAL; @@ -747,7 +747,7 @@ genkbd_event(keyboard_t *kbd, int event, void *arg) sc->gkb_flags &= ~KB_ASLEEP; wakeup(sc); } - selwakeup(&sc->gkb_rsel); + selwakeuppri(&sc->gkb_rsel, PZERO); } return 0; diff --git a/sys/dev/mse/mse.c b/sys/dev/mse/mse.c index bb79f28..408bbf7 100644 --- a/sys/dev/mse/mse.c +++ b/sys/dev/mse/mse.c @@ -751,7 +751,7 @@ mseintr(arg) sc->sc_flags &= ~MSESC_WANT; wakeup(sc); } - selwakeup(&sc->sc_selp); + selwakeuppri(&sc->sc_selp, MSEPRI); } } diff --git a/sys/dev/nmdm/nmdm.c b/sys/dev/nmdm/nmdm.c index 1511e9b..3227b11 100644 --- a/sys/dev/nmdm/nmdm.c +++ b/sys/dev/nmdm/nmdm.c @@ -451,11 +451,11 @@ wakeup_other(struct tty *tp, int flag) GETPARTS(tp, ourpart, otherpart); if (flag & FREAD) { - selwakeup(&otherpart->nm_tty.t_rsel); + selwakeuppri(&otherpart->nm_tty.t_rsel, TTIPRI); wakeup(TSA_PTC_READ((&otherpart->nm_tty))); } if (flag & FWRITE) { - selwakeup(&otherpart->nm_tty.t_wsel); + selwakeuppri(&otherpart->nm_tty.t_wsel, TTOPRI); wakeup(TSA_PTC_WRITE((&otherpart->nm_tty))); } } diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c index 6bbe200..48618e9 100644 --- a/sys/dev/random/randomdev.c +++ b/sys/dev/random/randomdev.c @@ -426,7 +426,7 @@ random_unblock(void) { if (!random_systat.seeded) { random_systat.seeded = 1; - selwakeup(&random_systat.rsel); + selwakeuppri(&random_systat.rsel, PUSER); wakeup(&random_systat); } } diff --git a/sys/dev/sab/sab.c b/sys/dev/sab/sab.c index 2eeb7f0..d8ac3d4 100644 --- a/sys/dev/sab/sab.c +++ b/sys/dev/sab/sab.c @@ -799,7 +799,7 @@ sabttystart(struct tty *tp) tp->t_state &= ~TS_SO_OLOWAT; wakeup(TSA_OLOWAT(tp)); } - selwakeup(&tp->t_wsel); + selwakeuppri(&tp->t_wsel, TTOPRI); if (tp->t_outq.c_cc == 0) { if ((tp->t_state & (TS_BUSY | TS_SO_OCOMPLETE)) == TS_SO_OCOMPLETE && tp->t_outq.c_cc == 0) { diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index d08ff3f..4c4115d 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -370,7 +370,7 @@ snp_in(snp, buf, n) snp->snp_flags &= ~SNOOP_RWAIT; wakeup(snp); } - selwakeup(&snp->snp_sel); + selwakeuppri(&snp->snp_sel, PZERO + 1); return (n); } @@ -444,7 +444,7 @@ snp_detach(snp) snp->snp_target = NODEV; detach_notty: - selwakeup(&snp->snp_sel); + selwakeuppri(&snp->snp_sel, PZERO + 1); if ((snp->snp_flags & SNOOP_OPEN) == 0) free(snp, M_SNP); diff --git a/sys/dev/sound/midi/midibuf.c b/sys/dev/sound/midi/midibuf.c index 8b4eda7..f444405 100644 --- a/sys/dev/sound/midi/midibuf.c +++ b/sys/dev/sound/midi/midibuf.c @@ -358,7 +358,7 @@ queuerawdata(midi_dbuf *dbuf, char *data, int len) /* Wake up the processes sleeping on input data. */ cv_broadcast(&dbuf->cv_in); if (SEL_WAITING(&dbuf->sel) && dbuf->rl >= dbuf->blocksize) - selwakeup(&dbuf->sel); + selwakeuppri(&dbuf->sel, PRIBIO); } static void @@ -399,5 +399,5 @@ deleterawdata(midi_dbuf *dbuf, int len) /* Wake up the processes sleeping on queueing. */ cv_broadcast(&dbuf->cv_out); if (SEL_WAITING(&dbuf->sel) && dbuf->fl >= dbuf->blocksize) - selwakeup(&dbuf->sel); + selwakeuppri(&dbuf->sel, PRIBIO); } diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index c17b219..7a1c906 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -116,7 +116,7 @@ chn_wakeup(struct pcm_channel *c) CHN_LOCKASSERT(c); if (SEL_WAITING(sndbuf_getsel(bs)) && chn_polltrigger(c)) - selwakeup(sndbuf_getsel(bs)); + selwakeuppri(sndbuf_getsel(bs), PRIBIO); wakeup(bs); } diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c index b398661..a57d6f8 100644 --- a/sys/dev/usb/ucom.c +++ b/sys/dev/usb/ucom.c @@ -875,7 +875,7 @@ ucomstart(struct tty *tp) CLR(tp->t_state, TS_SO_OLOWAT); wakeup(TSA_OLOWAT(tp)); } - selwakeup(&tp->t_wsel); + selwakeuppri(&tp->t_wsel, TTIPRI); if (tp->t_outq.c_cc == 0) { if (ISSET(tp->t_state, TS_BUSY | TS_SO_OCOMPLETE) == TS_SO_OCOMPLETE && tp->t_outq.c_cc == 0) { diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index bf73938..8740c3d 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -945,7 +945,7 @@ ugenintr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status) DPRINTFN(5, ("ugen_intr: waking %p\n", sce)); wakeup(sce); } - selwakeup(&sce->rsel); + selwakeuppri(&sce->rsel, PZERO); } Static void @@ -1005,7 +1005,7 @@ ugen_isoc_rintr(usbd_xfer_handle xfer, usbd_private_handle addr, DPRINTFN(5, ("ugen_isoc_rintr: waking %p\n", sce)); wakeup(sce); } - selwakeup(&sce->rsel); + selwakeuppri(&sce->rsel, PZERO); } Static usbd_status diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index c61e4ba..2451542 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -383,7 +383,7 @@ uhid_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status) DPRINTFN(5, ("uhid_intr: waking %p\n", &sc->sc_q)); wakeup(&sc->sc_q); } - selwakeup(&sc->sc_rsel); + selwakeuppri(&sc->sc_rsel, PZERO); if (sc->sc_async != NULL) { DPRINTFN(3, ("uhid_intr: sending SIGIO %p\n", sc->sc_async)); PROC_LOCK(sc->sc_async); diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c index f09fba7..dea1e0b 100644 --- a/sys/dev/usb/ums.c +++ b/sys/dev/usb/ums.c @@ -394,7 +394,7 @@ ums_detach(device_t self) } if (sc->state & UMS_SELECT) { sc->state &= ~UMS_SELECT; - selwakeup(&sc->rsel); + selwakeuppri(&sc->rsel, PZERO); } destroy_dev(sc->dev); @@ -533,7 +533,7 @@ ums_add_to_queue(struct ums_softc *sc, int dx, int dy, int dz, int buttons) } if (sc->state & UMS_SELECT) { sc->state &= ~UMS_SELECT; - selwakeup(&sc->rsel); + selwakeuppri(&sc->rsel, PZERO); } } Static int diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 846a82f..dd2e2b3 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -810,7 +810,7 @@ usb_add_event(int type, struct usb_event *uep) TAILQ_INSERT_TAIL(&usb_events, ueq, next); usb_nevents++; wakeup(&usb_events); - selwakeup(&usb_selevent); + selwakeuppri(&usb_selevent, PZERO); if (usb_async_proc != NULL) { PROC_LOCK(usb_async_proc); psignal(usb_async_proc, SIGIO); diff --git a/sys/dev/zs/zs.c b/sys/dev/zs/zs.c index f3687ff..7e58049 100644 --- a/sys/dev/zs/zs.c +++ b/sys/dev/zs/zs.c @@ -600,7 +600,7 @@ zsttystart(struct tty *tp) tp->t_state &= ~TS_SO_OLOWAT; wakeup(TSA_OLOWAT(tp)); } - selwakeup(&tp->t_wsel); + selwakeuppri(&tp->t_wsel, TTOPRI); if (tp->t_outq.c_cc == 0) { if ((tp->t_state & (TS_BUSY | TS_SO_OCOMPLETE)) == TS_SO_OCOMPLETE && tp->t_outq.c_cc == 0) { diff --git a/sys/fs/coda/coda_psdev.c b/sys/fs/coda/coda_psdev.c index debbdbf..133d0fd 100644 --- a/sys/fs/coda/coda_psdev.c +++ b/sys/fs/coda/coda_psdev.c @@ -526,7 +526,7 @@ coda_call(mntinfo, inSize, outSize, buffer) /* Append msg to request queue and poke Venus. */ INSQUE(vmp->vm_chain, vcp->vc_requests); - selwakeup(&(vcp->vc_selproc)); + selwakeuppri(&(vcp->vc_selproc), coda_call_sleep); /* We can be interrupted while we wait for Venus to process * our request. If the interrupt occurs before Venus has read @@ -664,7 +664,7 @@ coda_call(mntinfo, inSize, outSize, buffer) /* insert at head of queue! */ INSQUE(svmp->vm_chain, vcp->vc_requests); - selwakeup(&(vcp->vc_selproc)); + selwakeuppri(&(vcp->vc_selproc), coda_call_sleep); } } diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index f67bdbe..64337c4 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -999,7 +999,7 @@ apm_record_event(struct apm_softc *sc, u_int event_type) sc->event_ptr %= APM_NEVENTS; evp->type = event_type; evp->index = ++apm_evindex; - selwakeup(&sc->sc_rsel); + selwakeuppri(&sc->sc_rsel, PZERO); return (sc->sc_flags & SCFLAG_OCTL) ? 0 : 1; /* user may handle */ } diff --git a/sys/i386/isa/asc.c b/sys/i386/isa/asc.c index e304683..23a9801 100644 --- a/sys/i386/isa/asc.c +++ b/sys/i386/isa/asc.c @@ -525,7 +525,7 @@ ascintr(int unit) dma_restart(scu); } if (SEL_WAITING(&scu->selp)) { - selwakeup(&scu->selp); + selwakeuppri(&scu->selp, ASCPRI); } } } diff --git a/sys/i386/isa/cx.c b/sys/i386/isa/cx.c index fd5b686..a2a4693 100644 --- a/sys/i386/isa/cx.c +++ b/sys/i386/isa/cx.c @@ -546,7 +546,7 @@ cxoproc (struct tty *tp) tp->t_state &= ~TS_ASLEEP; wakeup(TSA_OLOWAT(tp)); } - selwakeup(&tp->t_wsel); + selwakeuppri(&tp->t_wsel, TTOPRI); } #endif splx (s); diff --git a/sys/i386/isa/istallion.c b/sys/i386/isa/istallion.c index f9bea0c..7f27ad7 100644 --- a/sys/i386/isa/istallion.c +++ b/sys/i386/isa/istallion.c @@ -1709,7 +1709,7 @@ static void stli_start(struct tty *tp) tp->t_state &= ~TS_ASLEEP; wakeup(&tp->t_outq); } - selwakeup(&tp->t_wsel); + selwakeuppri(&tp->t_wsel, TTOPRI); } #endif diff --git a/sys/i386/isa/mse.c b/sys/i386/isa/mse.c index bb79f28..408bbf7 100644 --- a/sys/i386/isa/mse.c +++ b/sys/i386/isa/mse.c @@ -751,7 +751,7 @@ mseintr(arg) sc->sc_flags &= ~MSESC_WANT; wakeup(sc); } - selwakeup(&sc->sc_selp); + selwakeuppri(&sc->sc_selp, MSEPRI); } } diff --git a/sys/i386/isa/spic.c b/sys/i386/isa/spic.c index a0afcb9..93985e4 100644 --- a/sys/i386/isa/spic.c +++ b/sys/i386/isa/spic.c @@ -433,7 +433,7 @@ spictimeout(void *arg) sc->sc_sleeping = 0; wakeup( sc); } - selwakeup(&sc->sc_rsel); + selwakeuppri(&sc->sc_rsel, PZERO); } spic_call2(sc, 0x81, 0xff); /* Clear event */ diff --git a/sys/i386/isa/stallion.c b/sys/i386/isa/stallion.c index fb5b51f..54d186d 100644 --- a/sys/i386/isa/stallion.c +++ b/sys/i386/isa/stallion.c @@ -1234,7 +1234,7 @@ static void stl_start(struct tty *tp) tp->t_state &= ~TS_ASLEEP; wakeup(&tp->t_outq); } - selwakeup(&tp->t_wsel); + selwakeuppri(&tp->t_wsel, TTOPRI); } #endif diff --git a/sys/i4b/driver/i4b_rbch.c b/sys/i4b/driver/i4b_rbch.c index d89e2c2..40f2c24 100644 --- a/sys/i4b/driver/i4b_rbch.c +++ b/sys/i4b/driver/i4b_rbch.c @@ -738,7 +738,7 @@ rbch_rx_data_rdy(int unit) { NDBGL4(L4_RBCHDBG, "unit %d, NO wakeup", unit); } - selwakeup(&rbch_softc[unit].selp); + selwakeuppri(&rbch_softc[unit].selp, TTIPRI); } /*---------------------------------------------------------------------------* @@ -759,7 +759,7 @@ rbch_tx_queue_empty(int unit) { NDBGL4(L4_RBCHDBG, "unit %d, NO wakeup", unit); } - selwakeup(&rbch_softc[unit].selp); + selwakeuppri(&rbch_softc[unit].selp, TTOPRI); } /*---------------------------------------------------------------------------* @@ -771,7 +771,7 @@ rbch_activity(int unit, int rxtx) { if (rbch_softc[unit].sc_cd) rbch_softc[unit].sc_cd->last_active_time = SECOND; - selwakeup(&rbch_softc[unit].selp); + selwakeuppri(&rbch_softc[unit].selp, TTIPRI); } /*---------------------------------------------------------------------------* diff --git a/sys/i4b/driver/i4b_tel.c b/sys/i4b/driver/i4b_tel.c index e13b5f4..c629a44 100644 --- a/sys/i4b/driver/i4b_tel.c +++ b/sys/i4b/driver/i4b_tel.c @@ -791,7 +791,7 @@ tel_connect(int unit, void *cdp) sc->devstate &= ~ST_RDWAITDATA; wakeup( &sc->result); } - selwakeup(&sc->selp); + selwakeuppri(&sc->selp, TTIPRI); } } @@ -835,7 +835,7 @@ tel_disconnect(int unit, void *cdp) sc->devstate &= ~ST_RDWAITDATA; wakeup( &sc->result); } - selwakeup(&sc->selp); + selwakeuppri(&sc->selp, TTIPRI); if (sc->devstate & ST_TONE) { sc->devstate &= ~ST_TONE; @@ -864,7 +864,7 @@ tel_dialresponse(int unit, int status, cause_t cause) sc->devstate &= ~ST_RDWAITDATA; wakeup( &sc->result); } - selwakeup(&sc->selp); + selwakeuppri(&sc->selp, TTIPRI); } } @@ -891,7 +891,7 @@ tel_rx_data_rdy(int unit) sc->devstate &= ~ST_RDWAITDATA; wakeup( &sc->isdn_linktab->rx_queue); } - selwakeup(&sc->selp); + selwakeuppri(&sc->selp, TTOPRI); } /*---------------------------------------------------------------------------* @@ -912,7 +912,7 @@ tel_tx_queue_empty(int unit) if(sc->devstate & ST_TONE) { tel_tone(sc); } else { - selwakeup(&sc->selp); + selwakeuppri(&sc->selp, TTIPRI); } } diff --git a/sys/i4b/layer4/i4b_i4bdrv.c b/sys/i4b/layer4/i4b_i4bdrv.c index d98fca6..95de760 100644 --- a/sys/i4b/layer4/i4b_i4bdrv.c +++ b/sys/i4b/layer4/i4b_i4bdrv.c @@ -820,7 +820,7 @@ i4bputqueue(struct mbuf *m) if(selflag) { selflag = 0; - selwakeup(&select_rd_info); + selwakeuppri(&select_rd_info, TTIPRI); } } @@ -863,6 +863,6 @@ i4bputqueue_hipri(struct mbuf *m) if(selflag) { selflag = 0; - selwakeup(&select_rd_info); + selwakeuppri(&select_rd_info, TTIPRI); } } diff --git a/sys/isa/psm.c b/sys/isa/psm.c index ef98da4..2c14bbe 100644 --- a/sys/isa/psm.c +++ b/sys/isa/psm.c @@ -2371,7 +2371,7 @@ psmintr(void *arg) sc->state &= ~PSM_ASLP; wakeup( sc); } - selwakeup(&sc->rsel); + selwakeuppri(&sc->rsel, PZERO); } } 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); } diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 63a914f..a0229a7 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -925,7 +925,7 @@ kqueue_wakeup(struct kqueue *kq) } if (kq->kq_state & KQ_SEL) { kq->kq_state &= ~KQ_SEL; - selwakeup(&kq->kq_sel); + selwakeuppri(&kq->kq_sel, PSOCK); } KNOTE(&kq->kq_sel.si_note, 0); } diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 031d081..b2ece2d 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -192,7 +192,7 @@ logtimeout(void *arg) return; } msgbuftrigger = 0; - selwakeup(&logsoftc.sc_selp); + selwakeuppri(&logsoftc.sc_selp, LOG_RDPRI); if ((logsoftc.sc_state & LOG_ASYNC) && logsoftc.sc_sigio != NULL) pgsigio(&logsoftc.sc_sigio, SIGIO, 0); if (logsoftc.sc_state & LOG_RDWAIT) { 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; diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 3208e5c..7b4667b 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -447,7 +447,7 @@ pipeselwakeup(cpipe) if (cpipe->pipe_state & PIPE_SEL) { cpipe->pipe_state &= ~PIPE_SEL; - selwakeup(&cpipe->pipe_sel); + selwakeuppri(&cpipe->pipe_sel, PSOCK); } if ((cpipe->pipe_state & PIPE_ASYNC) && cpipe->pipe_sigio) pgsigio(&cpipe->pipe_sigio, SIGIO, 0); diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 4bebd65..f34858c 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -2271,7 +2271,7 @@ ttwakeup(struct tty *tp) { if (SEL_WAITING(&tp->t_rsel)) - selwakeup(&tp->t_rsel); + selwakeuppri(&tp->t_rsel, TTIPRI); if (ISSET(tp->t_state, TS_ASYNC) && tp->t_sigio != NULL) pgsigio(&tp->t_sigio, SIGIO, (tp->t_session != NULL)); wakeup(TSA_HUP_OR_INPUT(tp)); @@ -2286,7 +2286,7 @@ ttwwakeup(struct tty *tp) { if (SEL_WAITING(&tp->t_wsel) && tp->t_outq.c_cc <= tp->t_olowat) - selwakeup(&tp->t_wsel); + selwakeuppri(&tp->t_wsel, TTOPRI); if (ISSET(tp->t_state, TS_ASYNC) && tp->t_sigio != NULL) pgsigio(&tp->t_sigio, SIGIO, (tp->t_session != NULL)); if (ISSET(tp->t_state, TS_BUSY | TS_SO_OCOMPLETE) == diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 2de3a04..874f0ba 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -326,11 +326,11 @@ ptcwakeup(tp, flag) struct pt_ioctl *pti = tp->t_dev->si_drv1; if (flag & FREAD) { - selwakeup(&pti->pt_selr); + selwakeuppri(&pti->pt_selr, TTIPRI); wakeup(TSA_PTC_READ(tp)); } if (flag & FWRITE) { - selwakeup(&pti->pt_selw); + selwakeuppri(&pti->pt_selw, TTOPRI); wakeup(TSA_PTC_WRITE(tp)); } } diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index d64198d..c4a4c09 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -308,7 +308,7 @@ sowakeup(so, sb) register struct sockbuf *sb; { - selwakeup(&sb->sb_sel); + selwakeuppri(&sb->sb_sel, PSOCK); sb->sb_flags &= ~SB_SEL; if (sb->sb_flags & SB_WAIT) { sb->sb_flags &= ~SB_WAIT; diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 4d4eb63..8e5dec2 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1744,7 +1744,7 @@ sohasoutofband(so) { if (so->so_sigio != NULL) pgsigio(&so->so_sigio, SIGURG, 0); - selwakeup(&so->so_rcv.sb_sel); + selwakeuppri(&so->so_rcv.sb_sel, PSOCK); } int diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index d64198d..c4a4c09 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -308,7 +308,7 @@ sowakeup(so, sb) register struct sockbuf *sb; { - selwakeup(&sb->sb_sel); + selwakeuppri(&sb->sb_sel, PSOCK); sb->sb_flags &= ~SB_SEL; if (sb->sb_flags & SB_WAIT) { sb->sb_flags &= ~SB_WAIT; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index dc9934b..8a49c13 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3375,7 +3375,7 @@ vn_pollevent(vp, events) */ vp->v_pollinfo->vpi_events = 0; /* &= ~events ??? */ vp->v_pollinfo->vpi_revents |= events; - selwakeup(&vp->v_pollinfo->vpi_selinfo); + selwakeuppri(&vp->v_pollinfo->vpi_selinfo, PRIBIO); } mtx_unlock(&vp->v_pollinfo->vpi_lock); } @@ -3394,7 +3394,7 @@ vn_pollgone(vp) VN_KNOTE(vp, NOTE_REVOKE); if (vp->v_pollinfo->vpi_events) { vp->v_pollinfo->vpi_events = 0; - selwakeup(&vp->v_pollinfo->vpi_selinfo); + selwakeuppri(&vp->v_pollinfo->vpi_selinfo, PRIBIO); } mtx_unlock(&vp->v_pollinfo->vpi_lock); } diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 1dc40c1..c282dcf 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -528,7 +528,7 @@ bpf_wakeup(d) if (d->bd_async && d->bd_sig && d->bd_sigio) pgsigio(&d->bd_sigio, d->bd_sig, 0); - selwakeup(&d->bd_sel); + selwakeuppri(&d->bd_sel, PRINET); KNOTE(&d->bd_sel.si_note, 0); } diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index 80d54e6..82ae3b9 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -475,7 +475,7 @@ tapclose(dev, foo, bar, td) } funsetown(&tp->tap_sigio); - selwakeup(&tp->tap_rsel); + selwakeuppri(&tp->tap_rsel, PZERO+1); tp->tap_flags &= ~TAP_OPEN; tp->tap_pid = 0; @@ -606,7 +606,7 @@ tapifstart(ifp) if ((tp->tap_flags & TAP_ASYNC) && (tp->tap_sigio != NULL)) pgsigio(&tp->tap_sigio, SIGIO, 0); - selwakeup(&tp->tap_rsel); + selwakeuppri(&tp->tap_rsel, PZERO+1); ifp->if_opackets ++; /* obytes are counted in ether_output */ } diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index b46cef6..e983a5b 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -213,7 +213,7 @@ tunstart(struct ifnet *ifp) } if (tp->tun_flags & TUN_ASYNC && tp->tun_sigio) pgsigio(&tp->tun_sigio, SIGIO, 0); - selwakeup(&tp->tun_rsel); + selwakeuppri(&tp->tun_rsel, PZERO + 1); } static void @@ -324,7 +324,7 @@ tunclose(dev_t dev, int foo, int bar, struct thread *td) } funsetown(&tp->tun_sigio); - selwakeup(&tp->tun_rsel); + selwakeuppri(&tp->tun_rsel, PZERO + 1); TUNDEBUG (ifp, "closed\n"); err = rman_release_resource(tp->tun_unit); diff --git a/sys/pc98/pc98/mse.c b/sys/pc98/pc98/mse.c index 406d8f3..fe55e7f 100644 --- a/sys/pc98/pc98/mse.c +++ b/sys/pc98/pc98/mse.c @@ -810,7 +810,7 @@ mseintr(arg) sc->sc_flags &= ~MSESC_WANT; wakeup(sc); } - selwakeup(&sc->sc_selp); + selwakeuppri(&sc->sc_selp, MSEPRI); } } diff --git a/sys/pccard/mecia.c b/sys/pccard/mecia.c index 59ef5b1..f3c5b11 100644 --- a/sys/pccard/mecia.c +++ b/sys/pccard/mecia.c @@ -499,7 +499,7 @@ mecia_reset(void *chan) #endif outb(MECIA_REG1, 0); - selwakeup(&slt->selp); + selwakeuppri(&slt->selp, PZERO); } static void diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c index 16f3a51..b1ef84a 100644 --- a/sys/pccard/pccard.c +++ b/sys/pccard/pccard.c @@ -162,7 +162,7 @@ disable_slot_to(struct slot *slt) else printf("pccard: card deactivated, slot %d\n", slt->slotnum); pccard_remove_beep(); - selwakeup(&slt->selp); + selwakeuppri(&slt->selp, PZERO); } /* diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c index 8e6677c..10271c9 100644 --- a/sys/pccard/pcic.c +++ b/sys/pccard/pcic.c @@ -980,7 +980,7 @@ pcic_reset(void *chan) sp->putb(sp, PCIC_TIME_CMD1, 0xf); sp->putb(sp, PCIC_TIME_RECOV1, 0); } - selwakeup(&slt->selp); + selwakeuppri(&slt->selp, PZERO); } /* diff --git a/sys/sys/condvar.h b/sys/sys/condvar.h index cf6a6c6..6b8b60c 100644 --- a/sys/sys/condvar.h +++ b/sys/sys/condvar.h @@ -59,7 +59,9 @@ int cv_timedwait(struct cv *cvp, struct mtx *mp, int timo); int cv_timedwait_sig(struct cv *cvp, struct mtx *mp, int timo); void cv_signal(struct cv *cvp); -void cv_broadcast(struct cv *cvp); +void cv_broadcastpri(struct cv *cvp, int); + +#define cv_broadcast(cvp) cv_broadcastpri(cvp, -1) void cv_waitq_remove(struct thread *td); void cv_abort(struct thread *td); diff --git a/sys/sys/selinfo.h b/sys/sys/selinfo.h index 9a03949..ac0db59 100644 --- a/sys/sys/selinfo.h +++ b/sys/sys/selinfo.h @@ -58,6 +58,7 @@ struct selinfo { void clear_selinfo_list(struct thread *td); void selrecord(struct thread *selector, struct selinfo *sip); void selwakeup(struct selinfo *sip); +void selwakeuppri(struct selinfo *sip, int pri); #endif #endif /* !_SYS_SELINFO_H_ */ |