comp.lang.ada
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
Subject: Re: GNAT: Unbounded_Strings
Date: 26 Jun 2001 14:23:24 +0200
Date: 2001-06-26T14:23:24+02:00	[thread overview]
Message-ID: <873d8nfn0j.fsf@deneb.enyo.de> (raw)
In-Reply-To: 87r8w7h8v4.fsf@deneb.enyo.de

Florian Weimer <fw@deneb.enyo.de> writes:

> "Maxim Reznik" <max1@mbank.com.ua> 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.



  reply	other threads:[~2001-06-26 12:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <9h9a9n$6bm$1@news.kiev.sovam.com>
2001-06-26  9:45 ` GNAT: Unbounded_Strings Florian Weimer
2001-06-26  9:46 ` Florian Weimer
2001-06-26 12:23   ` Florian Weimer [this message]
2001-06-26 13:58     ` Maxim Reznik
2001-06-26 15:28       ` Florian Weimer
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox