all mutexes -> read-write locks?

Alfred Perlstein alfred at freebsd.org
Mon Jun 2 17:35:38 UTC 2008


* Daniel Eischen <eischen at vigrid.com> [080602 10:14] wrote:
> On Mon, 2 Jun 2008, Julian Elischer wrote:
> >
> >how does that help making more things use read locking?
> 
> It doesn't, it shows one reason why mutexes can be different
> than read/write locks.
> 
> I don't see how most low-level leaf drivers can make use of
> read/write locks.  All they want to do is prevent simultaneous
> access to a device and setup I/O operations.
> 
> By keeping the mutex and rwlock APIs separate regardless of
> their implementation, you allow the code to specify what kind
> of locking it wants.  If you convert all mutexes to rwlocks
> you lose this information and it makes it harder to go back
> again.  On the other hand, if you s/mtx_foo/rw_foo/, you still
> have to analyze the code to tell whether or not you can
> truly turn them into simultaneous read locks.  So what is
> the harm in analyzing the code first, and then converting
> it to rwlocks IFF it can make use of it?

I agree with Daniel here.

I also think the following points are relevant:

1) we don't need to rototil the code to s/mtx/rw/ right now.
2) rw locks may not be as effecient as mtx later on and there's
   no point in doing it right now.

-- 
- Alfred Perlstein


More information about the freebsd-arch mailing list