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,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed.stanford.edu!sn-xit-02!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: CTips Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Tue, 08 Mar 2005 21:51:00 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <112sp515nirmhea@corp.supernews.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: en-us, en MIME-Version: 1.0 References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <112rs0bdr2aftdf@corp.supernews.com> <1inxxr988rxgg$.1w9dedak41k89.dlg@40tude.net> <112s1r0rf0o8nca@corp.supernews.com> <157t6st03yru3.124h9wuwhw9si$.dlg@40tude.net> In-Reply-To: <157t6st03yru3.124h9wuwhw9si$.dlg@40tude.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@supernews.com Xref: g2news1.google.com comp.lang.ada:8905 comp.lang.c++:44693 comp.realtime:1098 comp.software-eng:4655 Date: 2005-03-08T21:51:00-05:00 List-Id: Dmitry A. Kazakov wrote: > On Tue, 08 Mar 2005 15:13:20 -0500, CTips wrote: > > >>Dmitry A. Kazakov wrote: >> >> >>>On Tue, 08 Mar 2005 13:33:33 -0500, CTips wrote: >>> >>>protected type Atomic_Integer is >>> procedure Increment; >>>private >>> Value : Integer; >>>end Atomic_Integer; >>> >>>-- Implementation >>>protected body Atomic_Integer is >>> procedure Increment is >>> begin >>> Value := Value + 1; >>> end Increment; >>>end Atomic_Integer; >>> >> >>Will that generate: >> L0: >> lwlock temp,&Value >> add temp,temp,1 >> stwcond temp,&Value >> if( failed ) goto L0; >>or will it generate something much more heavy-weight. > > > Ask your compiler vendor. Though it wouldn't be necessarily polling. Also > usually protected objects are not used for so utterly fine-grained mutual > exclusion/locking. Atomic integer increment is normally just a small part > of some larger (but not lengthy) operation For example, placing something > in a queue. Umm...can be done without locking. See wait-free/lock-free algorithms. Therefore spinning for a lock (which probably would be the > implementation) will likely be less expensive than some tricky guards > attached to each and every instruction. You *REALLY* should see what can be done with lwlock/stwcond. You'll be suprised how cheap synchronization can be. > Note also that at such a low level > it would be very difficult if possible to maintain data consistency. > Compiler simply does not know what is related to what and will try to cope > with the worst case scenario. So, what escapes does the language provide to let you do this? None? >Protected types in Ada are to describe this > sort of semantics. So in the end atomic integers are pretty useless, no > matter how efficient they could be implemented. > That is one reason *NOT* to learn Ada; it restricts both choices and thinking.