comp.lang.ada
 help / color / mirror / Atom feed
From: jmills@ccrf-news.gatech.edu (John M. Mills)
Subject: Re: Easily-Read C++?
Date: 12 Oct 1994 09:35:24 -0400
Date: 1994-10-12T09:35:24-04:00	[thread overview]
Message-ID: <37goms$r30@siberia.gatech.edu> (raw)
In-Reply-To: 37en3i$sn7@gnat.cs.nyu.edu

WARNING: long-winded response follows:

In article <37en3i$sn7@gnat.cs.nyu.edu>, Robert Dewar <dewar@cs.nyu.edu> wrote:
>John (Mills), I assume that you see from my previous post that the question
>I posed is indeed a well defined one. I assumed that we are dealing with
>a volatile variable here, since otherwise all bets are off of course in
>the presence of concurrent access), but assuming the variable is atomic in
>the Ada sense (something you can't specify in C, but you can in practice
>count on, given a reasonable guess about the hardware and the compiler), 
>there is still a fundamental question: how many reads are you allowed,
>only 1, or are you allowed 2?

DISCLAIMER:  I am not a qualified language lawyer in either C or Ada!

Robert --

I apologize for missing the thrust of your posting.  I understand that C
defines the precedence, but not necessarily the order of evaluation of
elements of an r-value expression, so that implementation dependencies may
be encountered in using the unary ++ and -- pre- and post-fix operators.

Thus, I would not use an expression such as:
   y = ++x + x;

This is independent of the issue of parallel processes, whether interrupt-
activated or threaded.  I do not know whether judicious use of parentheses
can eliminate possible dependencies, either.

If the variable is declared 'volatile,' I would expect the compiler to read
the storage location each time I used the variable name in an expression or
control statement.  I would expect this is in Ada or C.  I don't know if this
removes all ambiguity in the case, for example, of a pointer-referenced
access.  (See DISCLAIMER.)

Were you suggesting that one thread of C code might intercede during the
evaluation of an expression on another thread?  Does Ada guarantee this
would never happen?  I am unsure what distinction you want to make here.
I took a quick look at the LRM index, but didn't turn up 'atomic.' Please
clue me on that.  Thanks.

We often use common variables and memory-mapped I/O in Ada to communicate
between tasks and between independent programs running on multiple processors
on a common VME bus.  We have had task-to-task interference in such cases,
on one processor.  In that case we could have used the rendezvous mechanism
to arbitrate the activity, but instead we created a lock/unlock package
which seems to work well.  I couldn't guarantee it immune to deadlock, but
it _will_ prevent invisible alteration of data by a competing task.  This could
be rewritten and used in C -- there's nothing special in our Ada.

I am quite interested in this question, as we encounter competitive access
fairly often in our designs.  We have taken the proverbial approach of
porcupines to sexual intercourse: we are very, _very_ careful! I have been
burned many times by this type of contention, and the most recent case
was in Ada.

I may still be missing the point.  If so, please excuse me and feel free to
try another tack -- maybe e-mail, since I'm rather obtuse.

Regards --jmm--

-- 
John M. Mills, SRE -- john.m.mills@gtri.gatech.edu -- (404)528-3258 (voice)
   Georgia Tech/ GTRI/ SDL, 7220 Richardson Rd., Smyrna, GA 30080
   "Well, I'm an Assistant Regurgitation Engineer --
     but I should make Senior R.E. next year" _The_Far_Side_, G. Larson



  reply	other threads:[~1994-10-12 13:35 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-10-05  3:00 Easily-Read C++? Ken Garlington
1994-10-05  9:42 ` Pierre Castori
1994-10-05 13:28   ` Robert Dewar
1994-10-06  2:20     ` Benjamin Ketcham
     [not found]     ` <CxDL8H.KGE@csn.org>
     [not found]       ` <milodCxH2E4.7F4@netcom.com>
     [not found]         ` <CxHJv0.Kw0@csn.org>
     [not found]           ` <DAG.94Oct11080229@bellman.control.lth.se>
     [not found]             ` <37du0k$ir2@gnat.cs.nyu.edu>
1994-10-12  3:19               ` Attractive comments better? R_Tim_Coslet
1994-10-13  1:35               ` Michael Feldman
1994-10-12 17:03           ` Easily-Read C++? John DiCamillo
1994-10-05 14:26 ` Eric S. Sessoms
1994-10-05 17:47 ` Kevin Cline
1994-10-05 22:02   ` Robert Dewar
1994-10-05 22:23     ` Richard Kenner
     [not found]       ` <124377@cup.portal.com>
1994-10-11 18:11         ` David Weller
1994-10-11 18:43         ` Robert Dewar
1994-10-12 13:15           ` Norman H. Cohen
1994-10-12 14:10             ` Robert Firth
1994-10-13 19:33             ` John D. Reading
1994-10-13  0:51         ` Keith Thompson @pulsar
1994-10-05 18:24 ` Magnus Kempe
     [not found] ` <EACHUS.94Oct6101347@spectre.mitre.org>
     [not found]   ` <371a3p$nos@gnat.cs.nyu.edu>
     [not found]     ` <1994Oct7.153254.29848@swlvx2.msd.ray.com>
     [not found]       ` <374uke$8mo@delphi.cs.ucla.edu>
     [not found]         ` <37bno4$ko4@gnat.cs.nyu.edu>
1994-10-11 13:00           ` Robert Firth
1994-10-11 13:44             ` Casper H.S. Dik
1994-10-11 19:03               ` Robert Dewar
1994-10-12 16:38               ` John DiCamillo
1994-10-11 18:52             ` Robert Dewar
1994-10-12 13:49               ` Norman H. Cohen
     [not found]           ` <37eej8$6ie@siberia.gatech.edu>
1994-10-11 18:55             ` Robert Dewar
1994-10-12 13:35               ` John M. Mills [this message]
1994-10-12 19:48                 ` Robert Dewar
     [not found]         ` <CxFr5B.K1G@news.otago.ac.nz>
     [not found]           ` <DAG.94Oct10075533@bellman.control.lth.se>
1994-10-11 17:50             ` Norman H. Cohen
     [not found]     ` <373vd2$39n@theopolis.orl.mmc.com>
     [not found]       ` <CxBvq7.GrH@inmet.camb.inmet.com>
     [not found]         ` <37bnic$kj2@gnat.cs.nyu.edu>
1994-10-11 18:02           ` Norman H. Cohen
     [not found] ` <1994Oct7.110309@di.epfl.ch>
     [not found]   ` <DAG.94Oct7204142@bellman.control.lth.se>
     [not found]     ` <1994Oct7.210111.4494@nosc.mil>
     [not found]       ` <374i3o$c87@Starbase.NeoSoft.COM>
1994-10-12 17:37         ` "Tag" (Was: Easily-Read C++? (NOT)) David Emery
     [not found] <3719k1$11gt@watnews1.watson.ibm.com>
     [not found] ` <85C92963672@annwfn.com>
1994-10-11 18:37   ` Easily-Read C++? Norman H. Cohen
1994-10-12 16:54     ` David Emery
1994-10-14 21:13       ` Kevin Cline
1994-10-21 14:38         ` Thomas M. Breuel
1994-10-22  3:10           ` Michael M. Bishop
1994-10-26  0:39             ` -mlc-+Schilling J.
1994-10-27 14:54               ` Bob Duff
1994-10-27 15:35                 ` Richard Kenner
1994-10-27 23:09                 ` Robert Dewar
1994-11-01 21:19                 ` Adam Beneschan
1994-11-02  0:46                   ` Bob Duff
  -- strict thread matches above, loose matches on Subject: below --
1994-10-12  3:06 Easily-Read C++ Ken Garlington
1994-10-14 10:50 Easily-Read C++? Bob Wells #402
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox