[coldfire-gnu-discuss] Making malloc threadsafe

Carlos O'Donell carlos at codesourcery.com
Mon Mar 12 04:24:00 UTC 2007


On Mon, Mar 12, 2007 at 12:22:49PM +1000, Daniel McLean wrote:
> 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? 

Which targets are you using? Coldfire GNU/Linux, Coldfire uCLinux?

Cheers,
Carlos.
-- 
Carlos O'Donell
CodeSourcery
carlos at codesourcery.com
(650) 331-3385 x716



More information about the coldfire-gnu-discuss mailing list