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
Direct mapping memory in popular OS?
- AndrewAPrice
- Member
- Posts: 2299
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: Direct mapping memory in popular OS?
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.
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.
My OS is Perception.
Re: Direct mapping memory in popular OS?
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
Besides *BSD, MacOSX, I am curious about Solaris, too.
I would be appreciated if somebody can shed some lights into this problem.
Thanks
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: Direct mapping memory in popular OS?
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 worksjunkoi wrote:MacOSX