What physical memory model should I use?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
LegendDairy
Member
Member
Posts: 52
Joined: Sat Nov 06, 2010 10:42 am
Location: Antwerp (Belgium)

What physical memory model should I use?

Post by LegendDairy »

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?
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: What physical memory model should I use?

Post by rdos »

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.
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.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: What physical memory model should I use?

Post by bluemoon »

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?
I don't allocate blocks for page table entry, instead, i mark a bit on the page directory and let it generate page fault.
In the PF handler i check the address if > 0xFFC00000 I allocate a page for it.
Post Reply