all, can anybody tell me that how to get a variable's physical address? (OS is Win7 64bit)
like:
void main()
{
int a=10;
........
return;
}
how can I get the physical address of variable 'a' ?
all, can anybody tell me that how to get a variable's physical address? (OS is Win7 64bit)
like:
void main()
{
int a=10;
........
return;
}
how can I get the physical address of variable 'a' ?
how can I get the physical address of variable 'a' ?
No, you can't.
The address you see refers to the virtual memory address
and not to the physical RAM address. The program runs on Virtual memory allocated by the OS. If a process starts executing, a process address space
is created for each process where all the information/data resides. For more info on process address space, click here.
in os case &a will print virtual address . virtual addresses are sometime have relations with physical address . to understand the relation of virtual address to physical address you need to understand the MMU of x86 and also windows 7 memory management part
Answer to Your question is &a
may give you the Physical Address of variable a
but If your code is loaded as part of the operating system and only if your operating system is running on a physical machine.
Note: If your operating system is running on a virtual machine, it will always give you virtual address or If your code is loaded as a regular application on a modern operating system, then also it will be a virtual address (logical address).