Article View: comp.lang.c++.moderated
Article #38Re: Meaning of the specifier volatile?
From: J. Kanze
Date: Thu, 11 Jan 1996 17:31
Date: Thu, 11 Jan 1996 17:31
43 lines
2760 bytes
2760 bytes
X-Original-Date: 11 Jan 1996 12:45:44 +0100
Tom Payne (thp@cs.ucr.edu) wrote:
|> J. Kanze (kanze@gabi-soft.fr) wrote:
|> [stuff deleted]
|> : On point concerning volatile that I have not seen made is the fact that
|> : the C/C++ concept of volatile is orthogonal to atomicity of access.
|> : Declaring an object volatile is *NOT* sufficient with regards to
|> : asynchronous events; the object must still be of a type for which the
|> : compiler will generate atomic accesses.
|> [stuff deleted]
|> Because of the signal-handlers-can't-read provision of the ANSI C
|> standard, atomicity is unnecessary in the coordination of asynchronous
|> activity for programs with defined behavior:
|> * signal handlers won't read any partially written non-atomic
|> shared variables, because they are not allowed to read variables
|> of static storage class in programs with defined behavior.
|> * the program itself won't read any partially written non-atomic
|> shared varible, because signal handlers don't return control
|> until they have completed their writes of volatile variables.
Close. The program itself won't read any partially written non-atomic
shared variables, because signal handlers are not allowed to write such
variables in programs with defined behavior.
Note that your statement, if allowed, could lead to anomalies if a
non-atomic read is interrupted, and the signal handler writes the
object. The first part of the read sees the old value, and the second
part the new value.
--
James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils, itudes et rialisations en logiciel orienti objet --
-- A la recherche d'une activiti dans une region francophone
[ 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:
<4d3hi9$qe2@netlab.cs.rpi.edu>Path:
arc1-ca.pugleaf.net!library.erc.clarkson.edu!rpi!not-for-mailReferences:
<4c9740$27n@netlab.cs.rpi.edu> <4cff74$gfj@netlab.cs.rpi.edu> <4cj5u4$qjm@netlab.cs.rpi.edu> <4cree9$9bv@netlab.cs.rpi.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!library.erc.clarkson.edu!rpi!not-for-mail From: kanze@gabi-soft.fr (J. Kanze) Newsgroups: comp.lang.c++.moderated,comp.lang.c++ Subject: Re: Meaning of the specifier volatile? Followup-To: comp.lang.c++.moderated,comp.lang.c++ Date: 11 Jan 1996 17:31:53 -0000 Organization: GABI Software, Sarl. Sender: cppmods@netlab.cs.rpi.edu Approved: vandevod@cs.rpi.edu Message-ID: <4d3hi9$qe2@netlab.cs.rpi.edu> References: <4c9740$27n@netlab.cs.rpi.edu> <4cff74$gfj@netlab.cs.rpi.edu> <4cj5u4$qjm@netlab.cs.rpi.edu> <4cree9$9bv@netlab.cs.rpi.edu> NNTP-Posting-Host: netlab.cs.rpi.edu