Page 1 of 1

Should I just page all memory into kernel

Posted: Sun Nov 06, 2005 2:25 pm
by iammisc
Hi!

I was wondering if I should just page all the memory into my kernel. So the virtual address 0x100 is physical address 0x100. Shouldn't the kernel control all the memory?

Thanks!

Re:Should I just page all memory into kernel

Posted: Sun Nov 06, 2005 2:28 pm
by Warrior
The kernel does (iirc) control all of it. What you want to manipulate it how much the user controls. I'm pretty sure the kernel can use "User" memory as well but I may be wrong.

I'd just page all the memory the kernel is loaded in then a kernel heap and make some global pages for video memory and stuff.

I'm just going from what I've read and understood so maybe it's better to let an OSDev guru handle this ;).

HTH (In some way ?:/)
Nelson

Re:Should I just page all memory into kernel

Posted: Sun Nov 06, 2005 2:49 pm
by Candy
iammisc wrote: I was wondering if I should just page all the memory into my kernel. So the virtual address 0x100 is physical address 0x100. Shouldn't the kernel control all the memory?
There's no should about it. There's only could.

You could make it have all memory. That gives a problem when there's lots (such as >1GB). You can't map more than 4GB in for example a 32-bit space, so you'd have to do something else, or claim that there's only 1GB or so.

The kernel SHOULD control memory however, but whether that's all is your own choice. Whether you want to extradite the memory control is also your choice.

OK, that was the official correct and not-at-all-helpful answer.

Helpful answer:

You could map in all memory and make the kernel control it all. Linux and Windows do that up to 990MB (dunno why that, but it is). You can tell Linux that since you have so much memory it shouldn't try (kernel compile option) and windows will just quit doing it automatically.

Most kernels control memory themselves. Microkernels offer the interface and leave the implementation to user level. Exokernels and such chop it up crudely and leave the mapping etc. to the "user level".

It's advisable to not map all memory and to control it all. That's the most common bit.


If you're not going to map it all, can you control it all?

Yes, most certainly. To control something you need a handle, not all of it. Handles to pages can be fit in 4 bytes each, which makes it possible for you to handle & control 1gb / 4 bytes * 4 kbytes = 1 TB of memory in 32-bit mode without wasting too much space. Hey, coincidence, that's exactly the limit of physical memory on an AMD64 system in 32-bit mode...

As long as you know where the memory is and what it's doing, you can leave it unmapped and don't care about it. Only when you need to do something about the page (such as wiping it or loading a page to it) do you need to map it in the kernel.

I need to start organizing my posts again...

HTH, Candy