A question about in lock usage in FreeBSD
matthew at FreeBSD.org
Tue Jun 13 13:58:46 UTC 2017
On 2017/06/13 13:59, Jia-Ju Bai wrote:
> I am a freshman in developing FreeBSD drivers, and I have a question in
> lock usage in FreeBSD.
> The kernel provides some kinds of locks in developing drivers, such as
> "mutex lock", "mutex spin lock", "rw lock" and "sx lock". I want to know
> which locks should be held when the thread can sleep.
> From my knowledge of FreeBSD document, I make the following points:
> (1) "rw lock" and "sx lock" can be used in this situation;
> (2) "mutex lock" and "mutex spin lock" are forbidden in this situation.
> If my points are right, I will make another point:
> mutex_lock will let the thread sleep when the lock is requested, so the
> mutex_lock can not be called in nested style (namely it is unsafe that
> mutex_lock is called again when a "mutex lock" is held).
> Are my points are right?
> I am looking forward to useful opinions and answers :)
I think you'll get better results if you ask your question on the
freebsd-hackers at freebsd.org mailing list. That way it will be seen by
people who are familiar with programming drivers and other internals of
the kernel and who will know precisely how to answer you.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 972 bytes
Desc: OpenPGP digital signature
More information about the freebsd-questions