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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c6acbb9f2027b8c9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!solnet.ch!solnet.ch!news-zh.switch.ch!switch.ch!news.hispeed.ch!linux2.krischik.com!news From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: volatile vs aliased Date: Fri, 07 Oct 2005 08:36:32 +0200 Organization: Cablecom Newsserver Message-ID: <2245220.uuDKIncv1a@linux1.krischik.com> References: <1128525722.605730.281980@g43g2000cwa.googlegroups.com> <87mzlnomca.fsf@ludovic-brenta.org> <1421562.dbAHjS9XJS@linux1.krischik.com> <1128598604.142021.239190@g44g2000cwa.googlegroups.com> <4fe1f.147855$dP1.505453@newsc.telia.net> NNTP-Posting-Host: 80-218-113-178.dclient.hispeed.ch Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8Bit X-Trace: news.hispeed.ch 1128667502 2324 80.218.113.178 (7 Oct 2005 06:45:02 GMT) X-Complaints-To: news@hispeed.ch NNTP-Posting-Date: Fri, 7 Oct 2005 06:45:02 +0000 (UTC) User-Agent: KNode/0.9.2 Xref: g2news1.google.com comp.lang.ada:5483 Date: 2005-10-07T08:36:32+02:00 List-Id: Bj�rn Persson wrote: > Rolf wrote: >> Do we have a difference to C/C++ increment operator here? consider >> >> pragma Volatile (x); >> x := x + 1; -- (1) >> vs. >> x++; -- (2) >> >> In the Ada case (1) we are forced to have "read from memory", >> "increment" and "write to memory" instructions, whereas in C/C++ (2) >> you can get a single "increment memory" instruction (presuming the >> mentioned assembler instructions exist on a given processor) > > Are there really memory chips with built-in arithmetic circuitry, so > that the processor can send an "add one" instruction to the memory and > have the variable incremented without reading it first? At least I've > never heard of that. As far as I know, adding and subtracting is the > processor's job. > > And why would you use pragma Volatile on a variable stored in the > memory, anyway? As Ludovic described it, it would only be useful on > variables mapped to special hardware devices. I don't think you would > want to store a counter there. Or you have a multi tasking application with C interface. Martin -- mailto://krischik@users.sourceforge.net Ada programming at: http://ada.krischik.com