public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>
To: shanem@netcom.com, libc-hacker@sourceware.cygnus.com
Subject: Re: how is malloc/free done in SMP linux
Date: Wed, 11 Aug 1999 14:58:00 -0000	[thread overview]
Message-ID: <19990811215539.31577.qmail@md.dent.med.uni-muenchen.de> (raw)
In-Reply-To: <19990811175647.A6AE957BB@ocean.lucon.org>

> > 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

      reply	other threads:[~1999-08-11 14:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <199908101513.IAA13569@netcom17.netcom.com>
1999-08-11 10:56 ` H.J. Lu
1999-08-11 14:58   ` Wolfram Gloger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19990811215539.31577.qmail@md.dent.med.uni-muenchen.de \
    --to=wmglo@dent.med.uni-muenchen.de \
    --cc=libc-hacker@sourceware.cygnus.com \
    --cc=shanem@netcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).