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.
Gigasoft wrote:Allocating means removing one from the list, and you free it put putting it back. Pages that do not correspond to usable RAM naturally won't be managed by the frame allocator or put on a free page list.
1. So every 4096 bytes in ram should have address of the next 4096 which would later change somehow?
2. How is the item removed/added from/to the list?
3. If page frames don't correspond to usable RAM then what are they for?
4. What is the usable RAM managed with then, if not PFA?
sj95126 wrote:I went with a different approach. I track the free frames as a linked list, where the pointer to the next frame is stored in the frame itself. So, I don't need any extra memory to track them, and finding a free frame is fast, because there's no searching - just take the first frame off the list. With paging, there's no need for the physical frames to be contiguous, so allocating multiple frames as a block isn't necessary.
A bit of late reply, but I just remembered about what you said about linked list of frames while I was implementing my PMM. I wanted to ask how are you doing this because if you have the pointer to next frame inside another frame then there are only 4096-8 bytes available, how do you handle it so the stuff which uses the page does not overwrite the place where address is stored?
The first 8 bytes of a page hold the address of the next page in the list, but you only need to do this while the page is part of the free list. When you allocate that page for use, remove it from the free list and set those first 8 bytes to 0 (presumably, you had already zeroed the rest of the page when you added it to the free list). Since it's no longer part of the free list, you can use all 4096 bytes.