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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a7dd909b9ed9f6d5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-26 05:07:36 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!151.189.0.75!newsfeed.germany.net!newsfeed2.easynews.net!easynews.net!news.cid.net!news.enyo.de!news1.enyo.de!not-for-mail From: Florian Weimer Newsgroups: comp.lang.ada Subject: Re: GNAT: Unbounded_Strings Date: 26 Jun 2001 14:23:24 +0200 Organization: Enyo's not your organization Message-ID: <873d8nfn0j.fsf@deneb.enyo.de> References: <9h9a9n$6bm$1@news.kiev.sovam.com> <87r8w7h8v4.fsf@deneb.enyo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Xref: archiver1.google.com comp.lang.ada:9113 Date: 2001-06-26T14:23:24+02:00 List-Id: Florian Weimer writes: > "Maxim Reznik" writes: > >> I propose another implementation of Unbounded_Strings using >> reference counting. > > Your implementation is not task safe, I was asked to explain this, so here we go. Have a look at the following code: declare A, B : Unbounded_String; begin A := Fetch_Some_Data; B := A; Do_Something_With (A); Do_Something_Else_With (B); end; Do_Something_With creates a task which continues to run after Do_Something_With returns. The task and Do_Something_Else_With both modify A and B at some point. According to the ARM (A) this is allowed: 3. The implementation shall ensure that each language defined subprogram is reentrant in the sense that concurrent calls on the same subprogram perform as specified, so long as all parameters that could be passed by reference denote nonoverlapping objects. A and B are clearly non-overlapping, so the situation describe above is completely valid, in particular, it does not result in erroneous execution. However, your code does not synchronize the two task when the a local copy of a shared string is made. As a result, your subprograms are not reentrant, and therefore not conforming to the implementation requirement quoted above.