[linux-audio-dev] malloc() in RT code considered not-so-harmful?
Tim Hockin
thockin at hockin.org
Wed Jul 14 05:18:12 UTC 2004
On Wed, Jul 14, 2004 at 05:58:25AM +0200, Ralf Beck wrote:
> Am Dienstag, 13. Juli 2004 22:50 schrieb Steve Harris:
> > 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>.
> > >
>
> malloc does not guarantee, that the allocated memory is locked into physical
> memory.
> To say it short: A RT thread must NEVER call a function that might block!!
The point was that an RT-safe malloc() could be safe, but it indicates a
bad design.
If your app starts up, does malloc(1024*1024*32); walks through that
memory to page it in, then mlock()s it, you can write a "safe" malloc to
allocate from that memory. But yuck.
Tim
More information about the Linux-audio-dev
mailing list