Locking a MTX_DEF inside an interrupt thread
Navdeep Parhar
nparhar at gmail.com
Thu Dec 11 19:58:41 UTC 2014
MTX_DEF mutexes can block but never sleep, and it is perfectly safe to acquire
them in an ithread.
On Thu, Dec 11, 2014 at 03:38:06AM -0300, Martin Galvan wrote:
> Hi everyone! I was reading the man page on bus_setup_intr() and
> noticed it warned against sleeping inside an ithread routine. However,
> I saw a few drivers that start their ithread routines by locking a
> MTX_DEF mutex, which I understand will make a thread sleep if the
> mutex is already being held by another thread. Based on that, I'd like
> to ask you guys a few questions:
>
> 1) Why can't we sleep inside an ithread? Isn't being able to
> context-switch (and thus avoiding using spinlocks) the whole point of
> using a separate thread for an interrupt handler?
> 2) What would be the 'correct' way to write an ithread routine which
> uses shared resources (such as a softc)?
> 3) Should we fix the drivers that use MTX_DEF mutexes inside their ithreads?
>
> Thanks a lot!
> _______________________________________________
> freebsd-drivers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-drivers
> To unsubscribe, send any mail to "freebsd-drivers-unsubscribe at freebsd.org"
More information about the freebsd-drivers
mailing list