468,554 Members | 1,470 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,554 developers. It's quick & easy.

virtual address or physical address?

hello,

my question is related with the address of a variable in C. suppose if
i am printing the address of a variable, so that address will be
virtual address or physical address. and why it'll be so?

is that has something to do with 16 bit environment and 32 bit
environment?

thanks in advance
sushant
Nov 14 '05 #1
9 3144
sushant <th********@rediffmail.com> scribbled the following:
hello, my question is related with the address of a variable in C. suppose if
i am printing the address of a variable, so that address will be
virtual address or physical address. and why it'll be so? is that has something to do with 16 bit environment and 32 bit
environment?


It is completely implementation-defined and outside the scope of the C
language standard. As far as the language goes, an address is an address
is an address.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"To know me IS to love me."
- JIPsoft
Nov 14 '05 #2
On Thu, 17 Feb 2005 22:21:11 -0800, sushant wrote:
hello,

my question is related with the address of a variable in C. suppose if
i am printing the address of a variable, so that address will be
virtual address or physical address. and why it'll be so?
It will be the address as the C program sees it. In a virtual memory
environmen that is likely to relate to a virtual address.
is that has something to do with 16 bit environment and 32 bit
environment?


Not really, no.

Lawrence
Nov 14 '05 #3
th********@rediffmail.com (sushant) wrote:
# hello,
#
# my question is related with the address of a variable in C. suppose if
# i am printing the address of a variable, so that address will be
# virtual address or physical address. and why it'll be so?

From the point of view of your program it doesn't matter if the addresses are
virtual or real; the hardware will handle all of that for you. If your system
does VM correctly the only visible sign could be real time delays between
some memory references due to page faults (or time slicing with other tasks).

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Who's leading this mob?
Nov 14 '05 #4
th********@rediffmail.com (sushant) writes:
my question is related with the address of a variable in C. suppose if
i am printing the address of a variable, so that address will be
virtual address or physical address.


No, not necessarily.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Nov 14 '05 #5
sushant wrote:
My question is related with the address of a variable in C.

If \I am print the address of a variable,
will that address be a virtual address or physical address?
Physical addresses are only visible in "supervisor" mode.
User application programs almost certainly print virtual addresses.
And why will it be so?

Does it have something to do
with 16 bit environment and 32 bit environment?


This is probably a reference
to "real" and "virtual" modes on x86 machines.

The original [16 bit] 8086 didn't implement virtual memory
so user application programs referenced (real) physical addresses.
The [32 bit] 80386 implemented virtual memory
but could be run in "real" mode to support [16 bit] legacy applications.
New [32 bit] applications were designed to run in virtual mode.
Nov 14 '05 #6
In article <cv**********@nntp1.jpl.nasa.gov>,
E.**************@jpl.nasa.gov says...
sushant wrote:
My question is related with the address of a variable in C.

If \I am print the address of a variable,
will that address be a virtual address or physical address?


Physical addresses are only visible in "supervisor" mode.
User application programs almost certainly print virtual addresses.


How do I get gcc -Wall -ansi -pedantic to generate code that will
use "supervisor mode" on my Ti MSP430? I checked the C spec
briefly and could not find a reference to "supervisor mode", could
you provide a reference?

--
Randy Howard (2reply remove FOOBAR)
"Making it hard to do stupid things often makes it hard
to do smart ones too." -- Andrew Koenig
Nov 14 '05 #7
Randy Howard wrote:
How do I get
gcc -Wall -ansi -pedantic
to generate code that will use "supervisor mode" on my Ti MSP430?
I checked the C spec briefly
and could not find a reference to "supervisor mode",
could you provide a reference?


I checked the MSP430x2xx Family User's Guide:

http://focus.ti.com/mcu/docs/techdoc...6&familyId=342

I don't think that
your machine has memory management or memory protection.

Apparently, it uses passwords to protect certain [flash] memory segments
(from accidental erasure).
It is always in "supervisor mode".
You can't and you don't need to do anything
to put your machine in "supervisor mode".

But, then, you already knew that didn't you?

Try the comp.dsp newsgroup if you need more details.
Nov 14 '05 #8
Randy Howard <ra*********@FOOverizonBAR.net> wrote:
# In article <cv**********@nntp1.jpl.nasa.gov>,
# E.**************@jpl.nasa.gov says...
# > sushant wrote:
# >
# > > My question is related with the address of a variable in C.
# > >
# > > If \I am print the address of a variable,
# > > will that address be a virtual address or physical address?
# >
# > Physical addresses are only visible in "supervisor" mode.
# > User application programs almost certainly print virtual addresses.
#
# How do I get gcc -Wall -ansi -pedantic to generate code that will

I use
cc x.c

--
SM Ryan http://www.rawbw.com/~wyrmwif/
You face forward, or you face the possibility of shock and damage.
Nov 14 '05 #9
Randy Howard wrote:
E.**************@jpl.nasa.gov says...
sushant wrote:
My question is related with the address of a variable in C.

If \I am print the address of a variable,
will that address be a virtual address or physical address?


Physical addresses are only visible in "supervisor" mode.
User application programs almost certainly print virtual addresses.


How do I get gcc -Wall -ansi -pedantic to generate code that will
use "supervisor mode" on my Ti MSP430? I checked the C spec
briefly and could not find a reference to "supervisor mode", could
you provide a reference?


Trolls don't seem to recognize when they are the butt of gibes.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Krishna Sagiraju | last post: by
8 posts views Thread by And | last post: by
4 posts views Thread by david | last post: by
16 posts views Thread by B Letts | last post: by
3 posts views Thread by Dhruba Bandopadhyay | last post: by
14 posts views Thread by Lorenzo | last post: by
1 post views Thread by =?Utf-8?B?QiBTaW5naA==?= | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.