Re: exclusive sleep mutex pcm0 (sound cdev) r = 0

From: Don Lewis <truckman_at_FreeBSD.org>
Date: Tue, 24 Feb 2004 08:11:25 -0800 (PST)
On 24 Feb, John Baldwin wrote:
> On Tuesday 24 February 2004 10:52 am, Don Lewis wrote:
>> On 24 Feb, John Baldwin wrote:

>> > Eek, why not a sx lock if you must go to a sleepable lock?
>>
>> That was my initial thought, but I was scared off by the following
>> statement in the sx(9) man page:
>>
>>      A thread may not own a shared lock and an exclusive lock
>> simultaneously; attempting to do so will result in deadlock.
>>
>> My plan is to hold this lock across large portions of the open() and
>> ioctl() methods (and possibly read() and write() as well).  Some of
>> these may call code outside of my direct control, such as methods in the
>> hardware specific drivers, as well as things like malloc().  I'm
>> concerned about causing a deadlock by violating the sx usage rules.
> 
> It means on the same lock, i.e. you can't try to do sx_slock(&foo) and then do 
> sx_xlock(&foo).  You can mix shared/exclusive of different locks ok.

Cool!  I'll make it an sx lock.

The man page should probably be clarified, maybe something like:

	A thread must not attempt to acquire a lock both shared and
        exclusive at the same time.  Such an attempt will result in a
        deadlock.
       
Received on Tue Feb 24 2004 - 07:11:45 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:44 UTC