LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 01: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, 08:02 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

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

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
s/most likely//

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

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

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


Reply



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 10:10 AM
Memory map or physical address of some memory allocated by malloc demon007 Programming 1 02-04-2012 06:17 AM
virtual memory address to physical address _Linux_Learner Linux - Newbie 1 04-14-2010 01:34 AM
accessing memory address outside standard mem einstern Linux - Software 3 11-23-2009 07:19 PM
Memory Mapping (same physical address = virtual address) skd.tech Linux - Kernel 7 07-24-2006 11:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:50 PM.

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
Open Source Consulting | Domain Registration