Implementing free page frame stack
Posted: Mon Sep 04, 2017 12:33 pm
Hi all,
I'm developing a physical memory manager for my kernel. I'd like to start with a free page stack scheme. However, I'm a little unsure about how to implement this. There's three options I can think of, but each have problems:
1. Have a linked list of free page frame addresses. When allocating or freeing frames, pop or push an element from/to the head of the list. However, how can I allocate nodes without the memory manager?
2. Have a linked list of free page frames, but use the frames themselves as list nodes. However, this requires directly accessing physical memory addresses which presents difficulties with paging. How can I access these frames from within a virtual address space?
3. Use a statically sized array of addresses as a stack. However, then I can only store a limited number of frames and would need a hybrid method.
I don't think (1) is feasible. For (2), maybe I could page in physical frames I need to access on demand? This sounds inefficient, but maybe it isn't. (3) sounds like the best to me but I want to start out with something simpler.
What are your opinions on these? Is there anything I haven't thought of? What implementations are you all using in your kernels?
Thanks,
Collin
I'm developing a physical memory manager for my kernel. I'd like to start with a free page stack scheme. However, I'm a little unsure about how to implement this. There's three options I can think of, but each have problems:
1. Have a linked list of free page frame addresses. When allocating or freeing frames, pop or push an element from/to the head of the list. However, how can I allocate nodes without the memory manager?
2. Have a linked list of free page frames, but use the frames themselves as list nodes. However, this requires directly accessing physical memory addresses which presents difficulties with paging. How can I access these frames from within a virtual address space?
3. Use a statically sized array of addresses as a stack. However, then I can only store a limited number of frames and would need a hybrid method.
I don't think (1) is feasible. For (2), maybe I could page in physical frames I need to access on demand? This sounds inefficient, but maybe it isn't. (3) sounds like the best to me but I want to start out with something simpler.
What are your opinions on these? Is there anything I haven't thought of? What implementations are you all using in your kernels?
Thanks,
Collin