Implementation of malloc

R

Raman

Hi All,
Can any one tell me how to implement malloc.
Thanks and Regards,
Raman Chalotra
 
C

Chris Dollin

Raman wrote:

(don't quote signatures)

Something broken when you quoted: my reply has been jammed on the end of
your question. Watch out for that.
Actually I Got this question in A Interview .

(fx:eyebrows) What's wrong with the one /they've/ got?

As I say, there's an example in K&R [1]. It's just code, apart from the
bit where you may have to interface to your local OS to claim free pages
or whatever it offers, and having to get alignments right. Lots of choices
to make. A /production/ malloc is, I'd guess, pretty hard to do well [2].

[1] Kernighan and Ritchie, The C Programming Language (second edition
preferred).

[2] But easy to do badly. Correctly, but badly.
 
F

Flash Gordon

Chris Dollin wrote, On 30/01/07 09:44:
You're thinking of alignment?

That is definitely a gotcha. You need to make some system specific
assumptions about what is enough to get the alignment correct for any type.
(I'm thinking of a large static array.)

When is sometimes a very good way of doing it.
 
C

Chris Thomasson

Raman said:
Hi All,
Can any one tell me how to implement malloc.
Thanks and Regards,
Raman Chalotra

Well, you can take a look at a high-performance multi-threaded allocator
algorithm I created:

http://groups.google.com/group/comp.arch/browse_thread/thread/24c40d42a04ee855

Seriously, my invention is actually one of the fastest atomically
thread-safe virtually zero-overhead memory allocators currently out there.
It beats the pants off HOARD and runs circles around Maged Michael's
so-called lock-free memory allocator...

http://portal.acm.org/citation.cfm?id=996848

I guess this is somewhat on topic simply because the pseudo-code
implementation of the invention is in C... I can't wait for this thing to be
properly released... So far I haven't come across anything like it. It
simply has excellent scalability and performance characteristics!

;^)


I am currently creating a website for the allocator where you will be able
to download a copy under a restrictive non-commercial license and experiment
with it all you want. Of course, commercial license agreements can be worked
out if you think this thing is worth integrating with some of your
existing/future commercial software suites...

Finally, I can basically prove that memory allocation can scale to many
thousands of cores, and many more indeed!


Take a look at the code and tell me what you think! Well, perhaps we should
move further discussions over on comp.programming.threads where is more on
"topic"...


Any thoughts/criticisms/suggestions on the invention?

Thank you all for your time!


:^)




Chris Thomasson
--------------

http://appcore.home.comcast.net/
(extremely scaleable lock-free abstractions for Intel-ASM/C/C++)

http://appcore.home.comcast.net/vzoom/refcount/
http://appcore.home.comcast.net/vzdoc/atomic/static-init/
(mostly lock-free atomic reference counting)

http://appcore.home.comcast.net/vzoom/round-1.pdf
http://appcore.home.comcast.net/vzoom/round-2.pdf
(scalability concerns anybody!?)


enjoy! ;^)




Any thoughts?
 
C

CBFalconer

Chris said:
You're thinking of alignment?

(I'm thinking of a large static array.)

That's good enough for a test bed. You also have to worry about
performing arithmetic with pointers, depending on the design.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
C

Christopher Layne

Chris said:
Seriously, my invention is actually one of the fastest atomically
thread-safe virtually zero-overhead memory allocators currently out there.
It beats the pants off HOARD and runs circles around Maged Michael's
so-called lock-free memory allocator...

Go back to comp.programming.threads please. There's only one newsgroup large
enough to take your constant "appcore" RFCs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top