From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1ff5003422436e4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-11 17:46:00 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!swiss.ans.net!cmcl2!thecourier.cims.nyu.edu!thecourier.cims.nyu.edu!nobody From: dewar@cs.nyu.edu (Robert Dewar) Newsgroups: comp.lang.ada Subject: Re: Easily-Read C++? Date: 11 Oct 1994 15:03:13 -0400 Organization: Courant Institute of Mathematical Sciences Message-ID: <37enhh$so6@gnat.cs.nyu.edu> References: <1994Oct7.153254.29848@swlvx2.msd.ray.com> <374uke$8mo@delphi.cs.ucla.edu> <37bno4$ko4@gnat.cs.nyu.edu> <1994Oct11.090047.9190@sei.cmu.edu> <37e4ri$7es@mail.fwi.uva.nl> NNTP-Posting-Host: gnat.cs.nyu.edu Date: 1994-10-11T15:03:13-04:00 List-Id: Casper, you say that shared access to global data requires locking. This plain isn't true, there are all sorts of algorithms that work fine with shared variables. THe purpose of volatile (in either Ada or C/C++) and of atomic in Ada, is precisely to facilitate this kind of usage. Sure in some sense it is cleaner not to use shared variables (in another context we would say it is cleaner not to use global variables, or even, if you are a functional programming fan, that it is cleaner not to use *any* variables). However, both C and Ada recognize that in certain cases, the use of shared variables is useful and legitimate (a bounded buffer with one consumer and one producer is a classical case, see for example the coding of the keyboard buffer in the PC BIOS). THe point is that Ada's definition is considerably more secure that C/C++ here. That's the original point I was making. Ada naturally has to worry about non-sequential semantics, since the standard includes non-sequential execution. In the C standard however, there is no serious consideration of concurrent semantics (that's what I mean by non-sequential here) because the language itself has no such notion. However, lots of C programs do have multiple threads and concurrent execution, and in such contexts, asking what is atomic, and how many times volatile variables are accessed is of semantic significance. Actually even in the absence of concurrent semantics, if a volatile variable refers to a memory mapped I/O location, it may be quite important to know how many times a variable is referenced, since the references may have external semantic effects. Of course a cautious programmer will simply avoid the use of ++mem for such a variable, but it is a little uncomfortable for things to be so ill-defined.