mem manager

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.
Post Reply
LongHorn

mem manager

Post 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?
chasetec

Re:mem manager

Post 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 :)
Bob the Avenger

Re:mem manager

Post 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
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re:mem manager

Post 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
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
ed_tait

Re:mem manager

Post 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.
Post Reply