OSDev.org

The Place to Start for Operating System Developers
It is currently Sun May 05, 2024 1:14 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Malloc()
PostPosted: Mon Jun 02, 2003 11:00 pm 
can anybody tell me how to rewrite malloc() free() realloc() so I can use them in a kernel?


Top
  
 
 Post subject: RE:Malloc()
PostPosted: Tue Jun 03, 2003 11:00 pm 
First of all, you must implement a kernel heap: if you reserve 256 MB for example you needn't allocate them, this is the role of the allocator.
You have several ways to code them:
- the easiest way is allocating pages on the heap for every allocation request: it is very fast, but if you allocate 2 bytes, your allocator will allocate 4096, causing a large waste of RAM.
- you can have buckets for every size of allocation (for example, 8 bytes, 16, 32, 64, 128, 256, 512, 1024, and so on) and pick the best fitting memory chunk

Also check out Doug Lea's dlmalloc, a fast and space-efficient heap allocator.


Top
  
 
 Post subject: RE:Malloc()
PostPosted: Thu Jun 12, 2003 11:00 pm 
There are some very usefull documents on Bonafide OS development.
http://osdev.neopages.net/tutorials.php ... sp;(Memory Management)

Hope this helps,
Daniel Raffler


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Amazonbot [bot], Bing [Bot], Google [Bot], Majestic-12 [Bot], nullplan and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group