Page 1 of 1
Best way to implement kernel heap manager
Posted: Fri Jan 07, 2011 9:48 am
by Peterbjornx
My current heap manager is a simple block based manager, but i've run into a design problem while working on paging, i need to be able to store the physical address per-block but as soon as the kernel heap starts expanding it wont be continuous in physical memory and i will need to store a per block physical base address, but this means i can't merge anymore and maximum physically continuous allocation size will be 4096-sizeof(kmm_block_hdr_t), so what is the best way to do this with the least memory overhead
Re: Best way to implement kernel heap manager
Posted: Fri Jan 07, 2011 10:04 am
by JamesM
Hi,
Peterbjornx wrote:My current heap manager is a simple block based manager, but i've run into a design problem while working on paging, i need to be able to store the physical address per-block but as soon as the kernel heap starts expanding it wont be continuous in physical memory and i will need to store a per block physical base address, but this means i can't merge anymore and maximum physically continuous allocation size will be 4096-sizeof(kmm_block_hdr_t), so what is the best way to do this with the least memory overhead
My rather generic response is: Why does your heap manager need to know anything about physical addresses?
Encapsulation and modularisation should help you solve the problem - the physical memory manager only should know about physical addresses; the heap should obtain memory via the virtual memory manager.
Re: Best way to implement kernel heap manager
Posted: Fri Jan 07, 2011 10:09 am
by Peterbjornx
well , i need to allocate address space for my page tables and directories, so i need to have some way of allocating both physical and virtual addresses at once
Re: Best way to implement kernel heap manager
Posted: Fri Jan 07, 2011 10:17 am
by JamesM
Peterbjornx wrote:well , i need to allocate address space for my page tables and directories, so i need to have some way of allocating both physical and virtual addresses at once
My response to that would be - why is it the heap's job to allocate space for your page tables and directories? page tables are the size of one page, so should be available direct from your physical memory manager...