Why use buddy algorithm?

From: Oliver (oliver.news_at_t-link.de)
Date: 07/30/03


Date: 30 Jul 2003 10:42:53 -0700

Hello,
I have a basic question about the memory management, not only in linux
but generally.

I read somewhere on the Net that Linux uses the buddy algorithm for
the physical memory management. So I conclude it has some advantage
over other methods. I understand how the buddy system works. But I
don't understand the advantage.

Let me try to make this clear.
What is the point contra my suggestion: In a virtual address space the
only and smallest parts of memory one has to manage are pages frames.
So I could use a list of all free page frames. This list has not to be
sorted in any way. If a process wants memory of one page, I take the
first entry, update the process' page table and return the new page
address in its process address space it can use from now on. If a
process needs more than one page I do the same but remove the first
entry as often as the number of pages it needs is. Then I have to
update the page table so that for the process all page frames seem to
be neighbours.
So far I have no disadvantage over the buddy algorithm?

If one page is freed, I take the entry back in my list in any position
for example the first. If more pages are freed I guess free() has to
handle the single pages. But it's the same for each page frame.

I see the advantage of the buddy alg. if you have different sizes of
memory that are allocated. And I also see that malloc() can use it to
manage the space inside one page, but I don't get the point for the
virtual address space management.

Perhaps someone can help me with that.

Oliver



Relevant Pages

  • Re: C++ Garbage Collector on VMS?
    ... worry about memory management in a virtual memory OS design. ... The Language and the Language Run-Time is generally left holding the proverbial bag, if the bag isn't passed directly to the programmer. ...
    (comp.os.vms)
  • Re: C++ sucks for games
    ... > language, including plain english. ... > dangling reference crop up in my code. ... references and memory management is a bit of a red herring here. ...
    (comp.lang.lisp)
  • Re: Memory Management scares me
    ... I kind of regret not having gone into programming at that ... It wasn't so much the idea of memory leaks as the idea of ... > are the driving factors for selecting customized memory management. ... simply replicates the entire data structure on each iteration, ...
    (comp.lang.cpp)
  • Re: OT: Comparison of Unix systems and window managers
    ... tricks to get quite a lot of memory. ... couldn't afford more than 512K. ... but not really good memory management. ... so the Mac meets my needs admirably. ...
    (rec.crafts.metalworking)
  • Re: Memory leak/gc.get_objects()/Improved gc in version 2.5
    ... The memory consumption of the program grows as the number of frames ... The memory usage vs. frame number graph shows some big "jumps" at ... I upgraded to Python 2.5. ...
    (comp.lang.python)