Re: [linux-audio-dev] malloc() in RT code considered not-so-harmful?

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] malloc() in RT code considered not-so-harmful?
From: Joshua Haberman (joshua_AT_reverberate.org)
Date: Tue Jul 13 2004 - 20:21:23 EEST


Steve Harris wrote:

> On Mon, Jul 12, 2004 at 10:15:05 -0700, Joshua Haberman wrote:
>
>>It seems plausible that you could use this to safely allocate memory
>>from RT threads. The only questions I have about its practicality are:
>
>
> Its not my experieince that you usually need to allocate memory in RT
> threads, the times when I've seen it done are mostly <generalisation>
> bacuase of bad design, excessive OO-ness or lack of knowledge of
> alloca(3) </generalisation>.

One reason I can think of is that you want to be sure to never, ever
drop a captured buffer when you are recording. You need buffers to send
the captured audio data to a disk thread, but without being able to call
malloc() from the audio thread, you have to pre-allocate a fixed amount
of memory for this purpose. No guess is high enough to guarantee that
you will never drop buffers, and the more you allocate in advance the
higher your overhead.

You could use a lock-free malloc as an emergency memory store for when
your pre-allocated buffers run out.

Josh


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Tue Jul 13 2004 - 20:48:50 EEST