Heap in Linux

Hi yours,

I am doing a simulation for studying purposes,
and need to know how Heaps are implemented in linux.
With a Heap I mean the memory managing thing, the thing you get by GetProcessHeap()
and not the mathematical datastructure of the same name.
I would like to hear some detailled explaination of the basic algorithms running
and the Heaps features.
Thanks in advance, drnick.

p.s. i'm asking this for windows in another thread too
LVL 5
drnickAsked:
Who is Participating?
 
sunnycoderCommented:
drnick,

Is it that you are looking at heap organization for the entire system or what is the algorithm used for memory allocation on the heap?

If former, then I think source at dmalloc.com might be helpful in deciphering the required information ...sorry I am not familiar with the organization of overall heap or for that matter who creates/maintains it

However, if you are looking at algorithm used for memory allocation on the heap, then it depends entirely on the implementation of the malloc function in your library .. system/compiler has nothing to do with it ...

generally,

a list of free memory blocks of different sizes is maintained ... this size is generally (mostly) power of 2 ... the minimum size maintained is the minimum amount of memory that can be allocated ... even if you request lesser memory, a whole block will be allocated.

When an allocation request is made, the smallest available block that will satisfy the request is returned ... If request cannot be satisfied, NULL is returned
0
 
drnickAuthor Commented:
sorry, copy-paste-error: GetProcessHeap is windows, okok
0
 
majorwooCommented:
drnick,

Seems alot like homework (which we are not allowed to do as you know) -- maybe start us off with what you know, and ask some more specific questions?

majorwoo
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
drnickAuthor Commented:
hi majorwoo,

I understand you concers well.
maybe i gotta specify a little more what i mean.
my question targets into that direction:
i am interested in how they work internally, what data structures and algorithms they use.
if i do HeapAlloc (in windows), for sure it will allocate memory for me,
but how does it this?
does it use kinda best-fit on a sequential set of memory pages, or returns it the first fitting free block?
is free memory handled by a free-space-list or do they come with buddy-processing?
I need to know this, because i am writing a simulation for heaps in general.
therefore, i asked this question on different os'es,
to let the use have a drop down list where she/he can decide, what os to simulate.
for academic purposes, you know.
so, this question is also not a homework, if any doubt occures, the programming will of course be done by myself, i just need some hints to make the simulations as precise as possible.
also, as you can see under my profile, i am a guy who has already answered some questions here, in different areas (and an average-a-student, who really would never ever ask someone to do his homework, to set record straight).
the thing is this: i am doing this for an international project for teaching of computer studies, the simulation'll be for other students and i'm doing this for zero money.
i have to do other stuff as well, and the only time, i can do some work on this, is sunday and tuesday afternoon, so i just want to enhance my perfomance with this question.
if experts maybe can describe in a short, understandable way, how the heap in their os works, and what it's main parameters are, i can process a lot faster.
If you're still questioning my integrity, than it is ok if you don't answer.
0
 
drnickAuthor Commented:
however, i elaborated on my question in the mac-os section a little more, so maybe that'll help anyone who wanna help me. thanks
0
 
Karl Heinz KremerCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by sunnycoder
Please leave any comments here within the next four days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

khkremer
EE Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.