November 5th, 2007, 05:57 AM
HEADBANGING: Pointer Access
My doubt is concerning CPU and MMU interaction with OSes.
Try executing the code on two different PCs, you'll get a constatnt value for each system.
Since 386s use MMUs for logical address -> physical address translation, is it possible for the CPU to directly access actual physical addresses?
Can the OS or software access actual physical addresses bypassing the MMU?
November 18th, 2007, 12:35 AM
your need to learn a bit more about memory on a computer, generally the kernel manages the physical RAM with the help of the MMU, the kernel tells the MMU what pages are for the user process then it loads the userspace app and the CPU lets the process run for a bit until something like an interrupt or an access to an unknown page occurs (the userspace process just sees the whole 4GB address space and accesses what it wants, if the CPU does not know about it triggers a page fault and tells the kernel)
what your seeing with your C code is virtual addresses, you probably have a similar architecture and kernel on both systems, that and the compiler used can determine the default value of a pointer (its undefined by C so never expect it to be a constant), the hardware address used is mapped with the help of the MMU to the virtual address the process sees
for accessing a hardware address directly you generally need to be running in kernel mode, though there are often ways to get the kernel to access the hardware address you want for you