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.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1a4f1da89a53b5ea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-09 20:42:43 PST Path: supernews.google.com!sn-xit-02!supernews.com!newsfeed.mesh.ad.jp!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Robert Dewar Newsgroups: comp.lang.ada Subject: Re: Pragma Atomic Date: Wed, 10 Jan 2001 04:27:37 GMT Organization: Deja.com Message-ID: <93gobj$u0c$1@nnrp1.deja.com> References: <93g48c$ehk$1@nnrp1.deja.com> NNTP-Posting-Host: 205.232.38.14 X-Article-Creation-Date: Wed Jan 10 04:27:37 2001 GMT X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; U) X-Http-Proxy: 1.0 x62.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 X-MyDeja-Info: XMYDJUIDrobert_dewar Xref: supernews.google.com comp.lang.ada:3848 Date: 2001-01-10T04:27:37+00:00 List-Id: In article <93g48c$ehk$1@nnrp1.deja.com>, Adam Beneschan wrote: > It wouldn't make sense to declare a scalar object, whose size > is a natural size on the processor, to be Atomic, since the > processor's reads and writes of > such an object would automatically be indivisible anyway. AARGH! It is this kind of thinking that leads to casually non-portable code. Just think about what you are saying, you are saying that if you write type x is mod 2 ** 64; v : x; and you know that you are operating on a 64-bit machine where 64-bit reads and writes are indivisible, and further more you happen to know that the compiler uses these instructions for reading and writing v, then you need not delare v Atomic because it is not needed! The whole point of Atomic is to *check* that your assumption that reads and writes are atomic is correct. It is not unusual in an Ada compiler for pragma Atomic to have no effect on the code that pragma Volatile would not have. THe difference is that you are asking the compiler to check that on the target you are using, you will indeed get Atomic access. So please declare v Atomic in the code above. It will have no effect on your 64-bit machine, but it will cause your code to be considered illegal when you port it to a 32-bit machine that does not support your expectations. > Atomic replaces Ada 83's pragma Shared. The name 'Shared' was > confusing, because the pragma was not used to mark variables > as shared." I'm not sure how the previous Shared pragma had > anything to do with indivisiblity or atomicity, Pleaes read the Ada 83 RM which makes this quite clear. > however, so I don't see how Atomic > replaces it. Because pragma Atomic in Ada 95 means EXACTLY the same think as pragma Shared in Ada 83. The name change was to avoid the confusing name (which certainly confused you :-) Sent via Deja.com http://www.deja.com/