On Wed, 31 Jan 2001, Alexander Indenbaum wrote:

> We have problem with program which fails to utilize all the CPUs on
> multi-proccessor machine. We suspect that all the threads wait on same
> mutex when they allocate memory since heap is shared.
> Is this true? How it can be solved?

it sounds quite very reasonable. any shared resource must be locked during
accesses, if its not a read-only resource. since memory mangement is not
cheap, a program that makes heavy use of malloc/free/new/delete or their
equivalents in other languages, will be affected by this locking.

how to ovrocme this:

1. use your own memory manager, with pre-allocation per thread.
2. implement (or look for) a memory allocator that creates a seperate heap
   for each thread. note that this method is more waistfull on memory
   resources, as pages cannot be shared by seperate threads.
3. fix your program to perform less memory allocation. store some data on
   the stack, for example. this path is usually hard, unless all a thread
   does is allocate a small chunk, use it and release it in a tight loop.

hope this helps.
--
guy

"For world domination - press 1,
 or dial 0, and please hold, for the creator." -- nob o. dy


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to