LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Is %p printed physical memory address or virual mem address? (https://www.linuxquestions.org/questions/linux-newbie-8/is-p-printed-physical-memory-address-or-virual-mem-address-4175482872/)

georgewhr 10-31-2013 01:55 AM

Is %p printed physical memory address or virual mem address?
 
Here is the simple code:
#include <stdio.h>

void main()
{
char a = 9;
char *ptr = &a;
printf("address is %p",ptr);
}

1, It printed out "address is 0xbfaf6745". Is that virtual addr or phyiscal addr?

2, I m actually kinda confusing about virual memory. So nobody actually gonna see physical memory address except kernel. Is this correct or not?

3, Let's take GPIO for another example. Say the GPIO base register address on a particualr microprosessor is 0x05000000. Is that virtual addr or physical addr?

rtmistler 10-31-2013 08:02 AM

It will most likely always show virtual, unless you are within kernel code. The GPIO is a physical address.

syg00 10-31-2013 08:09 AM

s/most likely//

There is also interrupt context of course.

johnsfine 10-31-2013 08:31 AM

%p prints whatever kind of address the pointer holds.

Any pointer that can be directly used as a pointer holds a virtual address.


All times are GMT -5. The time now is 05:38 PM.