From: Fons Adriaensen <fons.adriaensen@skynet.be>
To: "The Linux Audio Developers' Mailing List"
<linux-audio-dev@music.columbia.edu>
Cc: Paul Davis <paul@linuxaudiosystems.com>,
florin@sgi.com, linux-kernel@vger.kernel.org,
albert@users.sourceforge.net
Subject: Re: [linux-audio-dev] Re: desktop and multimedia as an afterthought?
Date: Wed, 14 Jul 2004 00:31:36 +0200 [thread overview]
Message-ID: <20040713223136.GB3009@linux> (raw)
In-Reply-To: <006401c46929$f3edf390$161b14ac@boromir>
On Tue, Jul 13, 2004 at 11:37:12PM +0100, Martijn Sipkema wrote:
> IMHO it is the lack of a mutex implementation with priority ceiling
> or inheritance and the stories about relying on either being a design
> problem that have caused the Linux audio community to not use
> mutexes and declare them non-RT safe while in fact they are
> required according to POSIX to synchronize memory between
> cooperating threads.
Does someone have an authoritive answer to the following question:
Will using try_lock() on a mutex ever block the caller ?
AFAIK it will not. If this is true I don't see the point of a
lock-free ring buffer at all. You will need some way to wake up the
non-RT thread anyway, in case it went to sleep when finding and
empty ring buffer. This same synchronisation method can be used
to share the state of the buffer between two threads.
For example if you use a counting semaphore (built using a condition
variable and a mutex), the RT thread would increment the sema for
every N samples it adds to a circular buffer, and the consumer will
decrement it for every N samples it reads. Then the state of the sema
at all times reflects the number of samples in the buffer.
If ever the V operation in the RT thread fails (unlikely, but possible
since it has to use try_lock()), it will remember this and increment
by one more the next time.
The point is that there is no need to use lock-free techniques to
maintain a shared sample count - it's already provided by the sync
mechanism which you need anayway. I've been using this method for
years in critical apps, and never seen it fail.
--
FA
next prev parent reply other threads:[~2004-07-13 22:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-12 20:45 desktop and multimedia as an afterthought? Albert Cahalan
2004-07-12 23:54 ` Paul Davis
2004-07-13 0:18 ` Con Kolivas
2004-07-13 1:11 ` Paul Davis
2004-07-13 3:25 ` Florin Andrei
2004-07-13 0:24 ` Andrew Morton
2004-07-13 1:49 ` Thomas Charbonnel
2004-07-13 10:22 ` Andrew Morton
2004-07-13 11:01 ` Thomas Charbonnel
2004-07-13 3:22 ` Florin Andrei
2004-07-13 8:30 ` Takashi Iwai
2004-07-13 11:09 ` Kasper Sandberg
2004-07-13 12:09 ` [linux-audio-dev] " Martijn Sipkema
2004-07-13 14:55 ` Paul Davis
2004-07-13 22:37 ` Martijn Sipkema
2004-07-13 22:31 ` Fons Adriaensen [this message]
2004-07-13 19:12 ` Bill Huey
2004-07-13 20:00 ` Lee Revell
2004-07-13 22:44 ` Martijn Sipkema
2004-07-13 22:08 ` Bill Huey
2004-07-13 23:37 ` Martijn Sipkema
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040713223136.GB3009@linux \
--to=fons.adriaensen@skynet.be \
--cc=albert@users.sourceforge.net \
--cc=florin@sgi.com \
--cc=linux-audio-dev@music.columbia.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@linuxaudiosystems.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.