* Re: how is malloc/free done in SMP linux
[not found] <199908101513.IAA13569@netcom17.netcom.com>
@ 1999-08-11 10:56 ` H.J. Lu
1999-08-11 14:58 ` Wolfram Gloger
0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 1999-08-11 10:56 UTC (permalink / raw)
To: Shane Miller; +Cc: GNU C Library
>
> Sir;
>
> i am beginning development of a CAD like program. it will be
> threaded and multi-processor capable (well thanks to SMP O/S
> like linux).
>
> as to the linux's memory management, suppose a program has
> 30 threads. each thread is allocating and deallocating memory.
>
> does linux block the other 29 threads when thread <X> wants
> to malloc/free? how about other threads/processes in the process
> table?
>
> in a regular, single-processor system, my original C++ program
> spent 50% of its time in malloc/free. i reduced this time very
> significantly by implementing memory pools. the basic algorithm is fairly
> easy to split up across threads. hence linux SMP for more performance.
> but i am wondering if i might be walking into a "technical snare"
> with respect to linux and memory management.
>
This has little to do with kernel. I forwarded this to the glibc
mailing list.
--
H.J. Lu (hjl@gnu.org)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: how is malloc/free done in SMP linux
1999-08-11 10:56 ` how is malloc/free done in SMP linux H.J. Lu
@ 1999-08-11 14:58 ` Wolfram Gloger
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Gloger @ 1999-08-11 14:58 UTC (permalink / raw)
To: shanem, libc-hacker
> > as to the linux's memory management, suppose a program has
> > 30 threads. each thread is allocating and deallocating memory.
> >
> > does linux block the other 29 threads when thread <X> wants
> > to malloc/free?
Usually, no. Only when two (or more) threads want to simultaneously
free() chunks from _one_ particular arena, all those threads except
for one will be blocked. In practice, this is very rare.
malloc() will actually _never_ block unless more memory is needed from
the kernel and the sbrk() or mmap() system call blocks.
> how about other threads/processes in the process
> > table?
Not quite sure, but generally I would expect them to be unaffected by
a malloc() or free() in a particular process, unless there is (heavy)
swapping activity going on.
> > in a regular, single-processor system, my original C++ program
> > spent 50% of its time in malloc/free. i reduced this time very
> > significantly by implementing memory pools. the basic algorithm is fairly
> > easy to split up across threads. hence linux SMP for more performance.
> > but i am wondering if i might be walking into a "technical snare"
> > with respect to linux and memory management.
Linux's malloc may perform well enough so you don't need to implement
pools yourself for SMP.
Regards,
Wolfram.
--
`Surf the sea, not double-u three...'
wmglo@dent.med.uni-muenchen.de
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-08-11 14:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <199908101513.IAA13569@netcom17.netcom.com>
1999-08-11 10:56 ` how is malloc/free done in SMP linux H.J. Lu
1999-08-11 14:58 ` Wolfram Gloger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).