I'm at a point in my kernel where I have to seriously work out how to handle my memory and there don't seem to be good information on how to do this.
First let me explain my basic design because a solution that doesn't fit won't be of much use to me. My memory layout looks currently like this:
0x000000 unused
0x100000 kernel image
0x130000 end of kernel
begin of usable physical ram for page tables
0x???FFF end of physical ram
0x000020000000 begin of kernel virtual ram
0x000100000000 begin of user virtual ram
0x7FFFFFFFFFFF end usable virtual ram
As you can see I work with a 64bit cpu and I use a 1:1 mapping of physical to virtual to manage page tables. I have a stack based handling of physical pages and can map pages to virtual addresses as I like. I have 2 memory pools for kernel and user. I want to use a flat address space and be able to share pages between processes for IPC.
Now the problem:
- For each process I need to know what pages it may read/write/execute. Specifically given an address what rights does the process have?
I need to overall know what addresses are free so allocation between processes never overlap.
I need to quickly find a large enough free region to contain a allocation request.
I need to free a region of memory from a processes address space, see if any other process still has pages in that region and mark all totaly unused pages as free again.
The only viable standard solution for memory management seems to be the buddy system. But to allocate a 4K page I would end up with 35 splits of my topmost buddy. Looking up a specific address would result in following up to 35 links which would be rather slow.
So what else is out there?
MfG
Mrvn