Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 May 2008 16:49:04 +0300
From:      Ilya Bobir <ilya@po4ta.com>
To:        Alexander Popov <aopopov@yahoo.com>
Cc:        freebsd-drivers@freebsd.org
Subject:   Re: Synchronization in drivers (after SMP improvements)
Message-ID:  <483D62D0.6070800@po4ta.com>
In-Reply-To: <600706.33129.qm@web51403.mail.re2.yahoo.com>
References:  <600706.33129.qm@web51403.mail.re2.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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().



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?483D62D0.6070800>