473,734 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

code for implementing buddy allocator

Hi
I am wondering if there is freely available code for a buddy memory
allocator. Specifically I am looking for code that will can break the
blocks across multiple levels and then merge them back together eg.
if the memory pools are 32k, 16k , 8k in size, then
a) if both 8K and 16K are exhausted and application asks for 8k block,
32 K should be broken into 16K fragments and then again into 8K(i.e.
the blocks are broken across multiple levels not just from 16K to 8K)
b) Whenever memory is released the blocks should be merged into 16K and
then back into 32K

Any suggestions will be appreciated.Tha nks

May 8 '06 #1
3 10661

<bh******@gmail .com> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. .
Hi
I am wondering if there is freely available code for a buddy memory
allocator. Specifically I am looking for code that will can break the
blocks across multiple levels and then merge them back together eg.
if the memory pools are 32k, 16k , 8k in size, then
a) if both 8K and 16K are exhausted and application asks for 8k block,
32 K should be broken into 16K fragments and then again into 8K(i.e.
the blocks are broken across multiple levels not just from 16K to 8K)
b) Whenever memory is released the blocks should be merged into 16K and
then back into 32K


I'm not sure if these will help. Doug Lea and John Walker have both written
respectable memory allocators. Although, recent information indicates
dlmalloc may perform better:

Doug Lea's dlmalloc
http://gee.cs.oswego.edu/dl/html/malloc.html

John Walker's BGET
http://www.fourmilab.ch/bget/
Rod Pemberton
May 8 '06 #2
I am working on this currently (for my physical memory manager), and
when it is done it will be merged into my subversion tree at
http://sourceforge.net/projects/xarnos. License will be MIT.

If thats good enough for you would you like an email when it's done? As
this is free software I'm making no guarentees it will ever actually
happen, but I'm getting there slowly :-) .

HTH,
Paul Barker

May 8 '06 #3
bh******@gmail. com wrote:

I am wondering if there is freely available code for a buddy memory
allocator. Specifically I am looking for code that will can break the
blocks across multiple levels and then merge them back together eg.
if the memory pools are 32k, 16k , 8k in size, then
a) if both 8K and 16K are exhausted and application asks for 8k block,
32 K should be broken into 16K fragments and then again into 8K(i.e.
the blocks are broken across multiple levels not just from 16K to 8K)
b) Whenever memory is released the blocks should be merged into 16K and
then back into 32K


It's not a buddy system, but has most of the characteristics you
specify. Take a look at nmalloc for DJGPP, available at:

<http://cbfalconer.home .att.net/download/nmalloc.zip>

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Also see <http://www.safalra.com/special/googlegroupsrep ly/>
May 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3021
by: David | last post by:
I am creating a web community site where each user can have a list of buddies. I have struck a bit of a problem though. I am designing my db model and have two entities called users containing usual stuff like password, name... and I have Buddy List. I also have the following relation. Users "have a" Buddy List The cardinality is that a user can have one buddy list and one buddy list is associated with one user.
12
2484
by: Paul | last post by:
Hi, Global operator new and delete are overloaded and I am using stl map to store pointers, but this code crashes, can some one shed some light??? Compiler: MS VC++ 6.0 STL: Shipped with Visual Studio. #include <malloc.h> #include <map>
3
2712
by: Sourin | last post by:
Hi all, I am trying to write code for my experiments. My work involves huge datasets, and as such my code needs to be memory efficient. I did some hand calculations regarding the amount of dynamic memory required for my datastructures ( used sizeof() to get the size of the structures ). But mallinfo() function show that approximately double that amount of memory is being allocated. I am working with gcc 3.2.2 on a redhat 9 machine. I...
27
2166
by: Pete | last post by:
I'm doing exercise 8-2 from "Accelerated C++" where we're supposed to implement library algorithms, trying to minimize the number of iterator operations. I have two questions so far. First, it took me a while to figure out how to get accumulate() to compile correctly: // begin and begin2 must both be input iterators.
14
2036
by: Gary Wessle | last post by:
Hi I wrote this routine below but getting the error below it which I don't know how to fix. thanks //useful.h /**
5
3173
by: fimarn | last post by:
I am trying to get rid of compile time error that I am getting only in RHEL5 (not in RHEL4) apparently due to the changes in the stl_list.h file. The error that I am getting is coming from the following code that attempts to remove an item from the list: class shm_objptr_list : public std::list < void*, SharedMemAlloc<void * > {
13
5036
by: Tristan Wibberley | last post by:
Hi I've got implementing overloaded operator new and delete pretty much down. Just got to meet the alignment requirements of the class on which the operator is overloaded. But how does one implement operator new/delete I can't see a way to indicate, on delete, how many objects must be destroyed (or how big the space is) - alternatively I can't figure out what are the alignment requirements so that the implementation, after calling my...
2
2170
by: Pallav singh | last post by:
Can we implement generic container like vector and set in shared memory region ( we get from Linux system calls shmget( ) , shmat( ) ) ?? i am facing problem in that ?
3
2824
by: vrsathyan | last post by:
Hi.., While executing the following code in purifier.., std::vector<int> vecX; vecX.clear(); int iCount = 0; { int iVal;
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.