All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bill Huey (hui) <bhuey@lnxw.com>
To: Martijn Sipkema <msipkema@sipkema-digital.com>
Cc: "Bill Huey (hui)" <bhuey@lnxw.com>,
	"The Linux Audio Developers' Mailing List" 
	<linux-audio-dev@music.columbia.edu>,
	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: Tue, 13 Jul 2004 15:08:38 -0700	[thread overview]
Message-ID: <20040713220838.GA22781@nietzsche.lynx.com> (raw)
In-Reply-To: <006901c4692b$074996f0$161b14ac@boromir>

On Tue, Jul 13, 2004 at 11:44:59PM +0100, Martijn Sipkema wrote:
[...]
> The worst case latency is the one that counts and that is the contended case. If
> you could guarantee no contention then the worst case latency would be the
> very fast uncontended case, but I doubt there are many (any?) examples of this in
> practice. There are valid uses of mutexes with priority inheritance/ceiling protocol;
> the poeple making the POSIX standard aren't stupid...

There are cases where you have to use priority inheritance, but the schemes that are
typically used either have a kind of exhaustive analysis backing it or uses a simple
late detection scheme. In a general purpose OS, the latter is useful for various kind
of overload cases. But if your system is constantly using that specific case, then it's
a sign the contention in the kernel must *also* be a problem under SMP conditions. The
constant use of priority inheritance overloads the scheduler, puts pressure on the
cache and other negative things that hurt CPU local performance of the system.

The reason why I mention this is because of Linux's hand-crafted nature of dealing
with this. These are basically contention problems expressed in a different manner.
The traditional Linux method is the correct method of deal with this in a general
purpose OS. This also applies to application structure as well. The use of these
mechanisms need to be thought out before application.

> > > It is often heard in the Linux audio community that mutexes are not realtime
> > > safe and a lock-free ringbuffer should be used instead. Using such a lock-free
> > > ringbuffer requires non-standard atomic integer operations and does not
> > > guarantee memory synchronization (and should probably not perform
> > > significantly better than a decent mutex implementation) and is thus not
> > > portable.
> > 
> > It's to decouple the system from various time related problems with jitter.
> > It's critical to use this since the nature of Linus is so temporally coarse
> > that these techniques must be used to "smooth" over latency problems in the
> > Linux kernel.

> Either use mutexes or POSIX message queues... the latter also are not
> intended for realtime use under Linux (though they are meant for it in
> POSIX), since they don't allocate memory on creation.
 
The nature these kind of applications push into a very demanding space where
typical methodologies surrounding the use of threads goes out the window. Pushing
both the IO and CPU resources of a kernel is the common case and often you have to
roll your own APIs, synchronization mechanisms to deal with these problem. Simple
Posix API and traditional mutexes are a bit too narrow in scope to solve these
cross system concurrency problems. It's not trivial stuff at all and can span
from loosely to tightly coupled systems, yes, all for pro-audio/video.

Posix and friends in these cases simply aren't good enough to cut it.

> > I personally would love to see these audio applications run on a first-class
> > basis under Linux. Unfortunately, that won't happen until it gets near real
> > time support prevasively through the kernel just like in SGI's IRIX. Multimedia
> > applications really need to be under a hard real time system with special
> > scheduler support so that CPU resources, IO channels can be throttled.
> > 
> > The techniques Linux media folks are using now are basically a coarse hack
> > to get things basically working. This won't change unless some fundamental
> > concurrency issues (moving to a preemptive kernel with interrupt threads, etc..)
> > change in Linux. Scattering preemption points manually over 2.6 is starting to
> > look unmanable from all of the stack traces I've been reading in these latency
> > related threads.
> 
> Improving the mutex and mqueue implementations to better support realtime
> use would be a significant improvement I think, making Linux quite suitable
> for realtime audio use.

Yes and no. This really all really needs to be hard real time in the long run.
With things like Tivo and other embedded application putting high demand on kernel
resources this kind of stuff needs to go into the Linux kernel sooner rather than
later so that Linux can keep up with current industry tracks.

That's my two cents. :)

bill


  reply	other threads:[~2004-07-13 22:09 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
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 [this message]
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=20040713220838.GA22781@nietzsche.lynx.com \
    --to=bhuey@lnxw.com \
    --cc=albert@users.sourceforge.net \
    --cc=florin@sgi.com \
    --cc=linux-audio-dev@music.columbia.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=msipkema@sipkema-digital.com \
    --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.