Making malloc threadsafe

Daniel McLean daniel.mclean at optusnet.com.au
Mon Mar 12 02:22:49 UTC 2007


Hi,

I was just wondering if it is possible to make malloc thread safe with 
Sourcery G++ Lite?  It seems that libc defines _malloc_lock and 
_malloc_unlock already.  If I make sure that all my calls to malloc in 
my code are thread safe (using mutual exclusion) will this ensure that 
memory allocation is in fact thread safe? Or are there places that 
malloc is called inside the C library such that without implementing 
_malloc_lock and _malloc_unlock malloc it won't be thread safe?

If so how can I make sure that malloc is thread safe? 

Thanks
Daniel



More information about the coldfire-gnu-discuss mailing list