tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: workqueues ....



Phil Nelson <phil%NetBSD.org@localhost> wrote:
> On Thursday 26 July 2018 23:23:13 Taylor R Campbell wrote:
> > static void
> > foo_intr(...)
> > {
> >         ...
> >         mutex_enter(&sc->sc_work_lock);
> >         if (!sc->sc_work_scheduled) {
> >                 workqueue_enqueue(sc->sc_wq, &sc->sc_work, NULL);
> >                 sc->sc_work_scheduled = true;
> >         }
> >         mutex_exit(&sc->sc_work_lock);
> >         ...
> > }
> 
> I was just wondering ... you show the intr enqueuing the work.
> Is it OK to have a callout enqueue work so one can enqueue
> work at some point in the future?

Yes, callout(9) will run the handler in a software interrupt.  As noted
before, you can acquire the adaptive locks in such context, but I would
recommend to keep the IPL parameters consistent (i.e. use IPL_SOFTCLOCK
or IPL_SOFTNET to demonstrate with which level you are synchronising).

You can find a decent overview of all this in the spl(9), softint(9) and
mutex(9) manual pages.

-- 
Mindaugas


Home | Main Index | Thread Index | Old Index