Synchronization in drivers (after SMP improvements)
Ilya Bobir
ilya at po4ta.com
Wed May 28 13:49:34 UTC 2008
Alexander Popov wrote:
> Hi, Benjamin, also Ilya,
>
>
> Thanks for your quick responses. mtx_sleep() would
> definitely help. Does it mean that user process executing in kernel space is
> guaranteed not to be preempted between mtx_lock() and mtx_sleep()? Because then
> I would get a sleeping thread with
> non-sleepable mutex anyway... or have I been in application
> development for too long? :-)
> Regards,
>
> Alexander.
>
>
According to locking(9) (" Context mode table." at the very bottom) the
only type of mutex you can use in your interrupt handler is a spin
mutex. And you are trying to synchronize with an interrupt handler.
So, the sc->mtx ought to be a spin mutex. While a spin mutex is held
all interrupts on the current CPU are blocked or deferred (mutex(9),
DESCRIPTION fifth paragraph) and the thread holding the mutex will not
be preempted.
And you should use msleep_spin().
More information about the freebsd-drivers
mailing list