tech-kern archive

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

RE: rw_lock vs mutex



A rw_lock allows multiple readers, correct?  If there's a non-trivial 
probability of concurrent reads that would make a difference.  If not, then a 
mutex would be just as good especially if that is lower overhead.

        paul

-----Original Message-----
From: tech-kern-owner%NetBSD.org@localhost 
[mailto:tech-kern-owner%NetBSD.org@localhost] On Behalf Of Matt Thomas
Sent: Thursday, February 02, 2012 8:53 PM
To: paul%whooppee.com@localhost
Cc: tech-kern%netbsd.org@localhost
Subject: Re: rw_lock vs mutex


On Feb 2, 2012, at 5:38 PM, Paul Goyette wrote:

> While digging around looking into another problem, I noticed that the 
> piixpm(4) driver uses an rw_lock for its ic_acquire_bus/ic_release_bus 
> routines.  ic_acquire_bus() uses rw_enter(..., RW_WRITER) and there doesn't 
> appear to be any use anywhere of RW_READER for that lock.
> 
> The man page for rw_lock implies that it is a superset of a mutex.  So I'm 
> wondering if it makes any sense to use the simpler mutex instead?

Switch to a mutex, it's much less overhead that a r/w lock


Home | Main Index | Thread Index | Old Index