On Wed, Nov 3, 2010 at 12:27 PM,  <m...@freebsd.org> wrote:
> It's not clear to me from the man pages (perhaps I didn't look at the
> right one?) in which environments I need a spinlock.  For example, I
> wouldn't think it's safe to use a MTX_DEF in a hard interrupt handler
> (i.e one that was registered with BUS_SETUP_INTR), but I see some code
> lying around here that does it and nothing I'm aware of has broken.

You can get either a hard interrupt handler(or fast handler in FreeBSD
parlance) or a soft handler using BUS_SETUP_INTR.  On FreeBSD 7 and
later fast interrupt handlers are passed to filter argument to
BUS_SETUP_INTR and soft handlers are passed to the ithread argument(on
earlier versions you had to pass the INTR_FAST flag to get a fast
handler).  You are correct that fast interrupt handlers may only
acquire spinlocks, not mutexes.  Soft interrupt handlers have their
own thread associated with them and so it's safe to acquire MTX_DEF
locks in that thread.

In your particular example you are running from the context of a
software interrupt thread, so you are safe to acquire MTX_DEF mutexes.
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to