Page 1 of 1

mem manager

Posted: Tue Jun 20, 2006 12:10 pm
by LongHorn
I am redesigning the memory manager once again, the first time i used stacks then bitmaps and now buddies. For the last time i haven't stored any information regarding the pages. Now should i store information about only the allocated pages or all the pages in the system. What you guys do?

Re:mem manager

Posted: Tue Jun 20, 2006 2:31 pm
by chasetec
I like the way Solaris does it. You have a list of all pages that get scanned for LRU pages for preemptive flushing(to swap) so that some memory is always free. But this scanning only happens with the current free memory has dropped below a certain threshold. The pages also have indicator of if they've been modified or not, that way we can discard pages if they havent' been modified and fall back to writing to swap/page file for the modified pages if we can't find enough unmodified LRU pages.

But then you have either different lists of pages or have one list with them grouped/flagged into categories. You have free pages which are pages that have never been used or have been used but the data wouldn't ever be reused like stack and heap areas of finished processes. Pages that were used for file caching but aren't used anymore are marked as free but they are less free then pages that where in stack and heap areas of old processes. When mallocs occur the system Solaris tries to use the really free pages first. That way if a file gets reread and it hasn't been modified since the last time it was read the system can reclaim the old pages instead of doing IO. You also have used and locked page categories/flags.

Personally I've never had time to do more then a bitmap :)

Re:mem manager

Posted: Tue Jun 20, 2006 3:40 pm
by Bob the Avenger
I've got/had a stack of free 4k chunks of physical memory, when ever i need one i just pop it off the top. It had good runtimes until i had to searchfor specific memory. For pages I'm going to impliment a hybrid list type thing

Re:mem manager

Posted: Wed Jun 21, 2006 2:04 pm
by Combuster
My kernel keeps a rendundant page table as follows:
the directory contains a pointer to each table, but also the amount of free pages therein. In each subpage, the amount of allocations is stored and the purpose of the page. This way i can keep track of shared pages, kernel pages (marked global), and whether a specific part of memory is used or not.

Note however, that i didn't coded out every detail of it yet, but at least i can allocate pages to waste on gdt's and idt's

Re:mem manager

Posted: Wed Jun 21, 2006 2:17 pm
by ed_tait
i've allso decided to redo my memory management. this time i've decided to go for a linked list format (free pagess have header with there size and link to the next free page). this would make searching and defraggmenting esyer.

as for the actual allocations i think a 'best fit' style algorithum i best fo me.