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!news4.google.com!news.glorb.com!newspeer1.se.telia.net!se.telia.net!masternews.telia.net.!newsc.telia.net.POSTED!not-for-mail From: =?ISO-8859-1?Q?Bj=F6rn_Persson?= User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: volatile vs aliased References: <1128525722.605730.281980@g43g2000cwa.googlegroups.com> <87mzlnomca.fsf@ludovic-brenta.org> <1421562.dbAHjS9XJS@linux1.krischik.com> <1128598604.142021.239190@g44g2000cwa.googlegroups.com> In-Reply-To: <1128598604.142021.239190@g44g2000cwa.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4fe1f.147855$dP1.505453@newsc.telia.net> Date: Thu, 06 Oct 2005 18:43:12 GMT NNTP-Posting-Host: 217.209.116.179 X-Complaints-To: abuse@telia.com X-Trace: newsc.telia.net 1128624192 217.209.116.179 (Thu, 06 Oct 2005 20:43:12 CEST) NNTP-Posting-Date: Thu, 06 Oct 2005 20:43:12 CEST Organization: Telia Internet Xref: g2news1.google.com comp.lang.ada:5459 Date: 2005-10-06T18:43:12+00:00 List-Id: 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. -- Bj�rn Persson PGP key A88682FD omb jor ers @sv ge. r o.b n.p son eri nu