Best way to implement kernel heap manager

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Peterbjornx
Member
Member
Posts: 116
Joined: Thu May 06, 2010 4:34 am
Libera.chat IRC: peterbjornx
Location: Leiden, The Netherlands
Contact:

Best way to implement kernel heap manager

Post 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
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Best way to implement kernel heap manager

Post 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.
Peterbjornx
Member
Member
Posts: 116
Joined: Thu May 06, 2010 4:34 am
Libera.chat IRC: peterbjornx
Location: Leiden, The Netherlands
Contact:

Re: Best way to implement kernel heap manager

Post 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
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Best way to implement kernel heap manager

Post 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...
Post Reply