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!news1.google.com!proxad.net!proxad.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: 12 Mar 2005 10:43:14 +0000 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: 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> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1110624297 5141 62.49.19.209 (12 Mar 2005 10:44:57 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sat, 12 Mar 2005 10:44:57 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: g2news1.google.com comp.lang.ada:9208 comp.lang.c++:45278 comp.realtime:1343 comp.software-eng:4910 Date: 2005-03-12T10:43:14+00:00 List-Id: Pascal Obry writes: > CTips writes: > > > > 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. Google shows me lwlock as a C function in the PostGres support groups; I don't know what machine architecture has these instructions? PowerPC? It could be used by any compiler as part of a low-level implementation, of course, but it's hardly likely that a C compiler could use it off its own bat. Why whould it want to unless you the programmer tells it to? If you're talking about assembler inserts in C -- for Pete's sake, we can insert assembler in Ada as a last resort if it's needed. What happens with lwlock about priority inversion? > > No protected type implementations will be so light. This is impossible as it > brings far more than atomic integer. For an atomic integer it is possible to > declare : > > Value : Integer; > pragma Atomic (Value); I don't think this will make Value := Value + 1; atomic, though! -- Simon Wright 100% Ada, no bugs.