Date: Thu, 11 Dec 2014 11:58:21 -0800 From: Navdeep Parhar <nparhar@gmail.com> To: Martin Galvan <omgalvan.86@gmail.com> Cc: freebsd-drivers@freebsd.org Subject: Re: Locking a MTX_DEF inside an interrupt thread Message-ID: <20141211195821.GA3827@ox> In-Reply-To: <CAN19L9FDgn9=UZ9E%2BhAxSQtFXtT=42zoBD0MvJwYW0_dx61nvw@mail.gmail.com> References: <CAN19L9FDgn9=UZ9E%2BhAxSQtFXtT=42zoBD0MvJwYW0_dx61nvw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141211195821.GA3827>