tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Fileassoc locking



On Sat, Dec 26, 2009 at 8:29 PM, Thor Lancelot Simon <tls%panix.com@localhost> 
wrote:
> On Sat, Dec 26, 2009 at 06:22:36PM -0500, Elad Efrat wrote:
>>
>> It is unclear to me why we need to hold a mutex (rather than merely a
>> reference) when traversing a list that will not change until reference
>> count has dropped. What am I missing? (See other mail about this as
>> well.)
>
> If the reference count manipulation is atomic, you do not, strictly
> speaking, need the locks (if you are clever).  However, that probably
> costs about as much as using a mutex, because the locked bus accesses
> are the expensive part of either.
>
> If the reference count manipulation is not atomic, you need the locks.

My question wasn't about why we need a mutex when changing the
reference count (these are mutex-protected) but rather why, once we
hold a reference, we need to lock a mutex as well. (Or simply lock a
mutex and not use a reference.)

-e.


Home | Main Index | Thread Index | Old Index