Hi
I'm looking for a plugin malloc() to use in my kernel (rather than reinvent the wheel myself) and found the Doug Lea's malloc.
I've read through the documentation and the Comments at the start but it looks really daunting. What sort of modifications will I need to make to it to use it for my kernel?
Also, are there any other alternatives that are ok, or is the dlmalloc the best one to use?
The other things that i've noticed are that it uses stdio.h. Surely, as we have no library, this can't work, or do we have to write these routines ourselves.
Otherwise, what algorithms could I use if I have to write the malloc myself?
thanks
srg
kernel malloc()
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:kernel malloc()
according to ftp://g.oswego.edu/pub/misc/malloc.c, stdio is required only to display statistics. If you don't need those statistics, i'd say you could easily remove all those stdio things.
The code will also appear a *lot* clearer if you ask your preprocessor to wipe out all those STDC or WIN32 conditional blocks ...
The code will also appear a *lot* clearer if you ask your preprocessor to wipe out all those STDC or WIN32 conditional blocks ...
Re:kernel malloc()
sorry... ;D
it does use an outside resource "yield()"
just replace
it does use an outside resource "yield()"
just replace
withwhile ( tsl(...) ) yield()
while ( tsl (...) ) /* empty */ ;
Re:kernel malloc()
I have ported dlmalloc to the core of my OS and it is very good, very fast and optimizes the memory usage by itself.Also, are there any other alternatives that are ok, or is the dlmalloc the best one to use?
The porting process is very easy.
Re:kernel malloc()
ooh, er, how do I do that?Pype.Clicker wrote:
The code will also appear a *lot* clearer if you ask your preprocessor to wipe out all those STDC or WIN32 conditional blocks ...
srg
Re:kernel malloc()
Here's a easy-to-port dlmalloc.
I have changed the malloc/free names to mm_alloc/mm_free but you can easily turn them to their default names.
I have changed the malloc/free names to mm_alloc/mm_free but you can easily turn them to their default names.
Re:kernel malloc()
Thanks very much!Neur0m'ancer wrote: Here's a easy-to-port dlmalloc.
I have changed the malloc/free names to mm_alloc/mm_free but you can easily turn them to their default names.
srg
Re:kernel malloc()
Here is an alternative (by Michael J. Haertel) to dlmalloc that I use,
http://www.pell.portland.or.us/~orc/Cod ... oc-930716/
All you need to do is provide certain headers for types and hook a morecore function.
Vivek
http://www.pell.portland.or.us/~orc/Cod ... oc-930716/
All you need to do is provide certain headers for types and hook a morecore function.
Vivek