MTX_DEF versus MTX_SPIN
Julian Elischer
julian at freebsd.org
Wed Nov 3 18:16:03 UTC 2010
On 11/3/10 10:17 AM, John Baldwin wrote:
> On Wednesday, November 03, 2010 1:04:13 pm mdf at freebsd.org wrote:
>>
>> So a MTX_DEF is okay in that environment?
> Yes. In fact, the reason to have threads for interrupt handlers is to allow
> interrupt handlers to use non-spin locks that block when the lock is held.
>
> MTX_SPIN locks are generally not needed in device drivers. The only reason a
> driver would use one is if it used a filter handler which does not run in a
> threaded context.
It should be noted that in the case where you really just want to spin
a few
instructions because some other thread is accessing a structure you want,
descheduling you. so you don't always incur the scheduling overhead.
More information about the freebsd-current
mailing list