[PLUG] Malloc and Glibc
Mathew, Tisson K
tisson.k.mathew at intel.com
Tue Nov 26 21:16:08 UTC 2002
I'm running glibc 2.2.2 on ARM/XScale with pthreads
Thanks
_tisson
-----Original Message-----
From: Karl M. Hegbloom [mailto:karlheg at pdxlinux.org]
Sent: Tuesday, November 26, 2002 12:59 PM
To: 'plug at lists.pdxlinux.org'
Cc: plug-devel at lists.pdxlinux.org
Subject: RE: [PLUG] Malloc and Glibc
[ Move to plug-devel ? ]
On Tue, 2002-11-26 at 08:50, Mathew, Tisson K wrote:
> Yes. It works perfectly fine with mutexes but I'm not sharing anything
other
> than the memory allocated by malloc. I wanted to avoid mutex locking for
> performance reasons. If malloc is already reentrant/thread safe, why
should
> I be doing extra locking?
I wonder if -D_REENTRANT does anything for "malloc"? My
"/usr/include/malloc.h" contains, near the top:
$Id: malloc.h,v 1.22 2002/03/12 21:58:54 drepper Exp $
`ptmalloc2', a malloc implementation for multiple threads without
lock contention, by Wolfram Gloger <wg at malloc.de>.
VERSION 2.7.0
It is owned by:
karlheg at bittersweet:~
% dpkg --search /usr/include/malloc.h
libc6-dev: /usr/include/malloc.h
karlheg at bittersweet:~
% dpkg --status libc6-dev | grep '^Version:'
Version: 2.3.1-5
So, the first question is, what version of libc are you working with?
(and on what distro, just out of curiosity?)
> -----Original Message-----
> From: Kyle Hayes [mailto:kyle_hayes at speakeasy.net]
> Sent: Tuesday, November 26, 2002 8:39 AM
> To: PLUG
> Subject: Re: [PLUG] Malloc and Glibc
>
> On Tuesday 26 November 2002 08:26, Mathew, Tisson K wrote:
> > A program that simply launches 10 threads that just malloc, wait 100
> > milliseconds, and free the data and then loop.
> >
> > This simple program segmentation faults. I'm using glibc version 2.2.2.
> > I was wondering if malloc has reentrancy problems or not ?
> >
> > Thoughts?
>
> Probably. You might need to set some define to make it threadsafe.
> Check... well, no, the malloc man page is from 1993. That's not going to
> help.
>
> Put mutexes around your calls to malloc. See if that helps. If not,
maybe
> you're doing something you shouldn't in your threads? Sharing a global
> variable by accident perhaps?
>
> Best,
> Kyle
_______________________________________________
PLUG mailing list
PLUG at lists.pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug
More information about the PLUG
mailing list