For example, any potential contention issue where two
execution threads want to read the same data
structures and don't want to write. A mutex serialises
these threads whereas a rw-semaphore would allow them
to execute concurrently.

The only example I can think of off the top of my head
is multiple simultaneous readers of the /proc
filesystem, which is contrived but would be easy to
arrange, even for non-privileged users.

Off the top of my head, I can't see why developers
would choose mutexes over rw-semaphores. If you take
the write-lock then you have exclusive access to the
resource, exactly as with a mutex. There's nothing
that says you can't read the resource as well, and so
I don't really understand your objection.

I suppose you're really recoiling from the prospect of
auditing the all ALSA code. However, I'm not
suggesting that anyone tear the whole code-base apart.
Some of the mutexes are declared static, which means
that they are file-local. Someone (e.g. me?) could
therefore modify them one-by-one and submit *small*
patches, provided I knew that I wouldn't be wasting my
time.

Cheers,
Chris

--- Paul Davis <[EMAIL PROTECTED]> wrote:
> >I have noticed that ALSA tends to use mutexes a lot
> >for its internal locking. Has anyone ever
> considered
> >using rw-semaphores instead? The biggest impact
> would
> >probably be to the /proc filesystem since it would
> >allow multiple concurrent readers, but I suppose
> that
> >it might also reduce other contention issues.
> 
> what contention issues? almost all the locks in ALSA
> are per-device
> (e.g. per PCM device), so unless you have 2 or more
> threads accessing
> the device at the same time, there is no contention.
> i haven't seen
> any source code that has such a design, and it would
> be quite odd
> given the synchronous nature of audio interfaces. i
> have seen very,
> very little locking that happens at the "top level"
> of ALSA. am i
> missing them?
> 
> in addition, its quite a tricky task to work through
> the code and
> decide whether a r-lock, w-lock or mutex is needed
> at any point in
> time, but i suspect that in most cases, a mutex is
> called for (i.e. we
> read and then write the value of a variable).
> 
> comments?
> 
> --p
> 


__________________________________________________
Do You Yahoo!?
NEW from Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

Reply via email to