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,e0e1d3b3f7c994b8 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!postnews.google.com!c33g2000hsd.googlegroups.com!not-for-mail From: gpriv@axonx.com Newsgroups: comp.lang.ada Subject: Re: Robert Dewar's great article about the Strengths of Ada over other langauges in multiprocessing! Date: Tue, 11 Mar 2008 17:32:18 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <13t4b2kkjem20f3@corp.supernews.com> <89af8399-94fb-42b3-909d-edf3c98d32e5@n75g2000hsh.googlegroups.com> <47D39DC8.20002@obry.net> <114f711c-9cf8-4fdb-8f11-77667afb8719@c33g2000hsd.googlegroups.com> NNTP-Posting-Host: 69.250.188.114 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1205281939 9749 127.0.0.1 (12 Mar 2008 00:32:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 12 Mar 2008 00:32:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c33g2000hsd.googlegroups.com; posting-host=69.250.188.114; posting-account=YaY8rAoAAAAAnFXOECY3BGVJsrvFJCgy User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20308 Date: 2008-03-11T17:32:18-07:00 List-Id: On Mar 11, 11:41 am, Vadim Godunko wrote: > On Mar 11, 4:58 pm, george.p...@gmail.com wrote: > > > This code is not multi-core safe. Are you sure that QString has > > Vtab? If not then comparison will be unfair. > > What is it "Vtab"? > > QString implemented in the same way as Universal_String. Both classes > internally use shared data - actual string and reference counter. > Operations on both classes are "reentrant" (see 1) and not "thread- > safe" (see 2). Both classes will be even not "reentrant" without > atomic increment/decrement operations. > > PS. > > (1) A reentrant function can be called simultaneously by multiple > threads provided that each invocation of the function references > unique data. > > (2) A thread-safe function can be called simultaneously by multiple > threads when each invocation references shared data. All access to the > shared data is serialized. Sorry for double post, did not get it through. Thanks for some useful education :-) VTab is virtual call table, created when class has at least one virtual function. That will make it similar to tagged record. Otherwise it will be similar to a plain Ada record and destructor may be inlined. So to be fair, your QString should have at least virtual destructor. That will cause indirect call to actual one. The constructors in C++ not virtual by definition, so to be totally equal should have virtual init and adjust that will be called from constructor and copy operator. That may get rid of your 4+ advantage. With C++ to be totally multicore thread safe, you need to make "volatile" all the data that has any possibility to be accessed from different threads. That makes access to this variables much slower. Otherwise, you may get incorrect readings once in a while. Few years back I spent months chasing these misreadings when moved heavily mullti-threded app to multi-core. These bugs are most nasty, since they rarely cause big trouble, manifesting themselves only once in a while (matter of weeks). Regards, George Privalov