|
![](/i/fill.gif) |
On 3/16/2012 4:41, Warp wrote:
> Darren New<dne### [at] san rr com> wrote:
>> You would be surprised at the number of implementations of malloc() and
>> free() that assume you're single-threaded and require locks.
>
> Care to give an example (in a modern OS)? At least Gnu libc uses locking
> malloc() and free() (and it's one of the reasons for their slowness).
I think you just answered the question.
Maybe I phrased my statement wrong. Lots of implementations of malloc() and
free() share a heap amongst multiple threads, so either need to lock
internally or need to be used from a single-threaded system. And hence, they
assume you're single threaded within the context of malloc/free because
they've acquired a global lock. I.e., yes, you get contention between
threads with manual memory management.
--
Darren New, San Diego CA, USA (PST)
People tell me I am the counter-example.
Post a reply to this message
|
![](/i/fill.gif) |