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

Reply via email to