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

Steve Harris S.W.Harris at ecs.soton.ac.uk
Tue Jul 13 20:50:04 UTC 2004


On Tue, Jul 13, 2004 at 10:21:23 -0700, Joshua Haberman wrote:
> >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.

Thats true, but that problem (running out of disk buffer) only happens in
extreme conditions, soft RT systems fail under lots of extreme conditions
awyway.

- Steve



More information about the Linux-audio-dev mailing list