Direct mapping memory in popular OS?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
junkoi
Member
Member
Posts: 63
Joined: Wed Jan 23, 2008 8:55 pm

Direct mapping memory in popular OS?

Post 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
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Direct mapping memory in popular OS?

Post 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.
My OS is Perception.
junkoi
Member
Member
Posts: 63
Joined: Wed Jan 23, 2008 8:55 pm

Re: Direct mapping memory in popular OS?

Post 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
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Direct mapping memory in popular OS?

Post 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
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Post Reply