ngx wrote:
I like the algorithm of managing pages with a linked list that acts like a stack. But the problem I have with it is that I think it will be extremely slow to initialize(it is only theory I haven't conducted any tests) if I run my OS on a real PC(oldest PC I can find has 8GB of RAM) or anything with like a GB of RAM or more, am I wrong somewhere? - Inserting address of next free frame in to each frame in the system would take a LONG time.
LONG time is relative. To a GHz CPU, yes, you'll have to write on the order of 20,000,000 words, all of which will probably result in a cache miss, and in CPU terms, it will take an age.
But in human terms, on that same GHz CPU, writing to DDR3 memory, how long do you realistically think it will take? It might be a significant fraction of a second, but I'd be surprised if it took more than a second. And it'll be done once, at boot up, when there is lots of other initialization going on as well, that all take several seconds.
But you can also fill the stack in parallel, like the idle task suggestion to clear pages.
ngx wrote:
Another problem I have is that what if a free frame is freed - then it will go into the linked list twice(or even more times) and could possibly get used by two different programs at the same time causing serious problems?
LOL, ha, welcome to C and systems programming.
I personally don't have that problem. My kernel is GC based, so page frames are only freed when they are no longer referenced.
ngx wrote:
Also - how do I allocate several consecutive frames(for huge pages...)?
That's also another argument for a hybrid system.
At the lowest level, manage pages using bitmap, which is easier to use for multiple page allocations.
But for zero pages, these tend to be used for anonymous mapped memory anyway, where you get no benefit from contiguous page allocations (page translation takes care of that)