Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Dec 2014 03:38:06 -0300
From:      Martin Galvan <omgalvan.86@gmail.com>
To:        freebsd-drivers@freebsd.org
Subject:   Locking a MTX_DEF inside an interrupt thread
Message-ID:  <CAN19L9FDgn9=UZ9E%2BhAxSQtFXtT=42zoBD0MvJwYW0_dx61nvw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAN19L9FDgn9=UZ9E%2BhAxSQtFXtT=42zoBD0MvJwYW0_dx61nvw>