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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.95.68 with SMTP id di4mr15673590obb.4.1399228202639; Sun, 04 May 2014 11:30:02 -0700 (PDT) X-Received: by 10.140.108.132 with SMTP id j4mr530228qgf.1.1399228202609; Sun, 04 May 2014 11:30:02 -0700 (PDT) Path: border2.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!c1no1380142igq.0!news-out.google.com!du2ni21233qab.0!nntp.google.com!ih12no418971qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 4 May 2014 11:30:02 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=206.53.78.59; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy NNTP-Posting-Host: 206.53.78.59 References: <7403d130-8b42-43cd-a0f1-53ba34b46141@googlegroups.com> <6c2cd5d4-a44c-4c18-81a3-a0e87d25cd9e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5e8b7087-5a92-4cd7-957a-c149a381a88b@googlegroups.com> Subject: Re: Safety of unprotected concurrent operations on constant objects From: sbelmont700@gmail.com Injection-Date: Sun, 04 May 2014 18:30:02 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Original-Bytes: 3183 Xref: number.nntp.dca.giganews.com comp.lang.ada:186211 Date: 2014-05-04T11:30:02-07:00 List-Id: On Sunday, May 4, 2014 11:57:02 AM UTC-4, Natasha Kerensikova wrote: >=20 > How would you "surround it with a mutex"? Do you mean a procedure in a >=20 > procted object, or some other scheme I'm not familiar with? >=20 begin Semaphore.Lock Map.Find("Something"); Semaphore.Unlock; end where 'Semaphore' is a protected object that blocks when locking, thus seri= alizing any access to the container. There are of course many other variat= ions on this theme. >=20 >=20 > However, if I start assuming the worst about standard containers, I >=20 > might soon slip down the slope towards assuming the worst about all >=20 > others standard features.=20 > And rightly so. =20 The problem is not that sharing constant data between tasks is not safe (it= is), the problem is that you are assuming internal operation of subprogram= s, which is bad ju-ju. For instance: pi : constant Float :=3D 3.14; is fine to access from multiple tasks, whereas calling this: function Get_Pi return Float; is never safe, even though you are A) not sharing and data and B) the resul= t in question won't ever change. It's also worth it to point out this portion of the 2012 rationale: "When the goals of the revision to Ada 2005 were discussed, one of the expe= ctations was that it would be possible to improve the containers, or maybe = introduce variants, that would be task safe. However, further investigation= revealed that this would not be practicable because the number of ways in = which several tasks could interact with a container such as a list or map w= as large." -sb