Hi,
I was redesigning my (physical)memory manager. My previous model was a bitmap but after I tried to track a bug and stepped into my code in GDB, I realized it is an insane amount of instructions. So I went back to the drawing board... I though of a stack model but then I couldn't pop a specific address, and it might return false information if a bug frees twice the same page. So I came up with a hybrid model: I would pop an address then pass it through the bitmap check if it is actually free. If I free a page I push the address and clear the bit. This makes it fast, reliable and only 3,12 % bigger than just a stack implantation and it should be allot faster then the bitmap.
So my question is: What do you think do you like it? Do you want to add something? Or should I use a different idea?
Also I've got a second question about my virtual manager. I've got a problem, every time when I allocate a virtual page, I allocate a physical one and then I map it in a table. The problem occurs when that table is full, then I need a new space that is mapped so that I can access it but I can't allocate one... How can I get around this? I solved this by mapping 4MB in the beginning of the initialization , then I can map my pages in that 4 MB region. But I don't like that solution... Has anyone got another idea?
What physical memory model should I use?
- LegendDairy
- Member
- Posts: 52
- Joined: Sat Nov 06, 2010 10:42 am
- Location: Antwerp (Belgium)
Re: What physical memory model should I use?
Sounds ok. Maybe you should also find some method to notify you that the same page is freed twice, so you could fix code that does this error? Then a production release could just assume that this never happens, and disregard the bitmap.Legendmythe wrote:Hi,
I was redesigning my (physical)memory manager. My previous model was a bitmap but after I tried to track a bug and stepped into my code in GDB, I realized it is an insane amount of instructions. So I went back to the drawing board... I though of a stack model but then I couldn't pop a specific address, and it might return false information if a bug frees twice the same page. So I came up with a hybrid model: I would pop an address then pass it through the bitmap check if it is actually free. If I free a page I push the address and clear the bit. This makes it fast, reliable and only 3,12 % bigger than just a stack implantation and it should be allot faster then the bitmap.
Re: What physical memory model should I use?
I don't allocate blocks for page table entry, instead, i mark a bit on the page directory and let it generate page fault.Legendmythe wrote:Also I've got a second question about my virtual manager. I've got a problem, every time when I allocate a virtual page, I allocate a physical one and then I map it in a table. The problem occurs when that table is full, then I need a new space that is mapped so that I can access it but I can't allocate one... How can I get around this? I solved this by mapping 4MB in the beginning of the initialization , then I can map my pages in that 4 MB region. But I don't like that solution... Has anyone got another idea?
In the PF handler i check the address if > 0xFFC00000 I allocate a page for it.