🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++.moderated
Article #25

Re: Meaning of the specifier volatile?

#25
From: Senthil
Date: Wed, 03 Jan 1996 09:28
42 lines
1920 bytes
X-Original-Date: Tue, 02 Jan 1996 15:25:49 -0800

Srinivas Vobilisetti wrote:
> 
> X-Original-Date: 31 Dec 1995 01:42:27 GMT
> 
> Hello,
>

Concept of volatile can be easily using a simple example:

int a

a = 1;
a++
if (a==1) {
	...
}

typically compiler loads the value of variable a, into a register of a processor 
before executing 'a++'. and compares the value of register that holds the value 
instead of checking the value at the actual memory location. This optimization is default
in any C compiler. If suppose the location of variable a is a hardware location like
printer port, this optimization won't work, to supress such optimization we add the keyword
volatile, In that case compiler generate instruction to fetch from actual location instead
of fetching value from register.


 
> I referred to various books on C++ including The C++ Programming Language
> -Bjarne Stroustrup, C++ Primer -Stanley Lipmann, etc.  Nowhere i could find
> exact meaning of the specifier volatile. Thanks in advance for your help. I
> would appreciate the reply at my email address srv@cs.wayne.edu
> 
> Thanks
> Srinivas
> srv@cs.wayne.edu

    [ comp.lang.c++.moderated is a moderated newsgroup.  Submit articles ]
    [  to <c++-submit@netlab.cs.rpi.edu>.  The moderation policy can be  ]
    [   retrieved from <http://netlab.cs.rpi.edu/~cppmods/guide.html>.   ]
    [    Moderators can be reached at: c++-request@netlab.cs.rpi.edu.    ]
Technical Details
Message-ID: <4cdi7r$ci9@netlab.cs.rpi.edu>
Path: arc1-ca.pugleaf.net!library.erc.clarkson.edu!rpi!not-for-mail
References: <4c9740$27n@netlab.cs.rpi.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!library.erc.clarkson.edu!rpi!not-for-mail
From: Senthil <senthil@genmagic.com>
Newsgroups: comp.lang.c++.moderated,comp.lang.c++
Subject: Re: Meaning of the specifier volatile?
Date: 3 Jan 1996 09:28:27 -0000
Organization: GENERAL MAGIC
Sender: cppmods@netlab.cs.rpi.edu
Approved: kanze@gabi-soft.fr
Message-ID: <4cdi7r$ci9@netlab.cs.rpi.edu>
References: <4c9740$27n@netlab.cs.rpi.edu>
NNTP-Posting-Host: netlab.cs.rpi.edu