Locking a MTX_DEF inside an interrupt thread
Martin Galvan
omgalvan.86 at gmail.com
Thu Dec 11 06:38:07 UTC 2014
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!
More information about the freebsd-drivers
mailing list