General questions regarding where a memory manager belongs
Posted: Fri Nov 14, 2014 4:43 pm
I've planned out how I want my memory manager to work, but I have a few questions about best practices regarding where I should put it.
My general idea for a basic memory manager is that each block will have a header containing :
Status (ie, free/allocated)
Size of block
Pointer to next block
Pointer to previous block
Blocks will be split/combined as needs dictate. However, I'm wondering where I should put the code for the initialization of my memory manager. I'm thinking that the kernel should check the GRUB multiboot header to learn where all the initial blocks are and create the initial headers. Obviously my C library will have malloc() and such to allocate the blocks and stuff, but if my memory manager exists in the kernel, how should I get malloc() to comunicate with it? Shouldn't my C library be as kernel independent as possible? Is it 'best practice' to add something like malloc_init() function that takes over from the memory manager once it's done reading the multiboot header?
My general idea for a basic memory manager is that each block will have a header containing :
Status (ie, free/allocated)
Size of block
Pointer to next block
Pointer to previous block
Blocks will be split/combined as needs dictate. However, I'm wondering where I should put the code for the initialization of my memory manager. I'm thinking that the kernel should check the GRUB multiboot header to learn where all the initial blocks are and create the initial headers. Obviously my C library will have malloc() and such to allocate the blocks and stuff, but if my memory manager exists in the kernel, how should I get malloc() to comunicate with it? Shouldn't my C library be as kernel independent as possible? Is it 'best practice' to add something like malloc_init() function that takes over from the memory manager once it's done reading the multiboot header?