Maged Michael from IBM, who is publishing lots of practical lock-free
algorithms these days, has just published a paper describing a
lock-free memory allocation algorithm:
http://www.research.ibm.com/people/m/michael/pldi-2004.pdf
It seems plausible that you could use this to safely allocate memory
from RT threads. The only questions I have about its practicality are:
1. how easy/possible is it to use two malloc() implementations in the
same program? My brief research suggests that mixing system malloc(3)
and sbrk(2) (the latter is the underlying mechanism for obtaining more
memory from the OS) is not guaranteed to be safe. A possible solution
I have encountered is to obtain memory from the OS by mmap(/dev/zero)
instead of using sbrk(2).
2. When your lock-free malloc needs more memory from the OS it will
still take a system call to do it. I believe I have heard it said in
the past that system calls of any sort are unacceptable in RT code, but
isn't this a bit a of a hard-line position?
Josh