- 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
This commit is contained in:
parent
2e55d247a6
commit
512824f8f7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=122352
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -2371,7 +2371,7 @@ psmintr(void *arg)
|
||||
sc->state &= ~PSM_ASLP;
|
||||
wakeup( sc);
|
||||
}
|
||||
selwakeup(&sc->rsel);
|
||||
selwakeuppri(&sc->rsel, PZERO);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -751,7 +751,7 @@ mseintr(arg)
|
||||
sc->sc_flags &= ~MSESC_WANT;
|
||||
wakeup(sc);
|
||||
}
|
||||
selwakeup(&sc->sc_selp);
|
||||
selwakeuppri(&sc->sc_selp, MSEPRI);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
}
|
||||
|
||||
|
@ -525,7 +525,7 @@ ascintr(int unit)
|
||||
dma_restart(scu);
|
||||
}
|
||||
if (SEL_WAITING(&scu->selp)) {
|
||||
selwakeup(&scu->selp);
|
||||
selwakeuppri(&scu->selp, ASCPRI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -751,7 +751,7 @@ mseintr(arg)
|
||||
sc->sc_flags &= ~MSESC_WANT;
|
||||
wakeup(sc);
|
||||
}
|
||||
selwakeup(&sc->sc_selp);
|
||||
selwakeuppri(&sc->sc_selp, MSEPRI);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -2371,7 +2371,7 @@ psmintr(void *arg)
|
||||
sc->state &= ~PSM_ASLP;
|
||||
wakeup( sc);
|
||||
}
|
||||
selwakeup(&sc->rsel);
|
||||
selwakeuppri(&sc->rsel, PZERO);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do a wakeup when a selectable event occurs.
|
||||
*/
|
||||
/* 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.
|
||||
*/
|
||||
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;
|
||||
|
@ -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);
|
||||
|
@ -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) ==
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -810,7 +810,7 @@ mseintr(arg)
|
||||
sc->sc_flags &= ~MSESC_WANT;
|
||||
wakeup(sc);
|
||||
}
|
||||
selwakeup(&sc->sc_selp);
|
||||
selwakeuppri(&sc->sc_selp, MSEPRI);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,7 +499,7 @@ mecia_reset(void *chan)
|
||||
#endif
|
||||
outb(MECIA_REG1, 0);
|
||||
|
||||
selwakeup(&slt->selp);
|
||||
selwakeuppri(&slt->selp, PZERO);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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);
|
||||
|
@ -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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user