LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-31-2013, 02:55 AM   #1
georgewhr
Member
 
Registered: Nov 2012
Location: SF Bay Area
Posts: 47

Rep: Reputation: Disabled
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?
 
Old 10-31-2013, 09:02 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,087
Blog Entries: 10

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
It will most likely always show virtual, unless you are within kernel code. The GPIO is a physical address.
 
Old 10-31-2013, 09:09 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,838

Rep: Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822
s/most likely//

There is also interrupt context of course.
 
Old 10-31-2013, 09:31 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181
%p prints whatever kind of address the pointer holds.

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading from a physical memory address mrthaggar Linux - Newbie 5 01-14-2013 11:10 AM
Memory map or physical address of some memory allocated by malloc demon007 Programming 1 02-04-2012 07:17 AM
virtual memory address to physical address _Linux_Learner Linux - Newbie 1 04-14-2010 02:34 AM
accessing memory address outside standard mem einstern Linux - Software 3 11-23-2009 08:19 PM
Memory Mapping (same physical address = virtual address) skd.tech Linux - Kernel 7 07-25-2006 12:13 AM


All times are GMT -5. The time now is 10:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration