Page 1 of 1

Direct mapping memory in popular OS?

Posted: Mon Mar 09, 2009 2:50 am
by junkoi
Hi,

I am wondering if any other popular OS use the same direct mapping memory as Linux?

In Linux, they can translate virtual address to physical address using the formula:

physical-addr = virtual-addr - 0xC0000000

This is called "direct-mapping" in Linux. Of course to use the above formula, the virtual address must falls with a particular range (like [0xC0000000, 0xC0000000+896MB].

My question is: is there any other OS use the same "direct-mapping" technique?

I am particular interested in the answer for popular OS like *BSD, MacOSX, *nix.

Thanks a lot,
J

Re: Direct mapping memory in popular OS?

Posted: Mon Mar 09, 2009 3:18 am
by AndrewAPrice
As far as I know, most operating system's code is directly mapped like this.

Especially in the very early stages of bootup when your memory manager isn't set up correctly, it's really easy to do a 1:1 mapping of the higher half of memory to the lower half. Virtually every high-half kernel does this on boot up.

But once memory management is initialised and working, as far as I know, the pages are then mapped from all over the physical RAM into the kernel. Otherwise you'd get have limited memory (you'd have to shift physical RAM around when you want to allocate another page to the kernel) and I see no benefit.

But for non-dynamic addresses and the such (that were allocated before the memory manager), then I see how the "phys addr = virt addr - start of kernel" would be a helpful macro to resolve the address. Otherwise, it's not too hard to go resolve an address from a page directory/table manually.

Re: Direct mapping memory in popular OS?

Posted: Mon Mar 09, 2009 9:18 pm
by junkoi
At least I heard that Windows does not use the direct-mapping technique. I dont know why they dont do that!

Besides *BSD, MacOSX, I am curious about Solaris, too.

I would be appreciated if somebody can shed some lights into this problem.

Thanks

Re: Direct mapping memory in popular OS?

Posted: Tue Mar 10, 2009 8:54 am
by Troy Martin
junkoi wrote:MacOSX
You can download the Darwin kernel source for free and I bet you these invisible tokens that you could figure out how their memory map works :D