From: "Alex R. Mosteo" <alejandro@mosteo.com>
Subject: Re: Status of AdaCL: Ada Class Library
Date: Thu, 25 Feb 2010 15:16:17 +0100
Date: 2010-02-25T15:16:17+01:00 [thread overview]
Message-ID: <7unf1hF7anU1@mid.individual.net> (raw)
In-Reply-To: u3a0py05h.fsf@stephe-leake.org
Stephen Leake wrote:
> "Randy Brukardt" <randy@rrsoftware.com> writes:
>
>> Am 22.02.2010, 02:51 Uhr, schrieb Björn Persson <bjorn@rombobjörn.se>:
>>
>>> I had intended to switch from Charles to Ada.Containers, but I changed
>>> my mind when I learned that Ada.Containers can't even be read by
>>> multiple
>> > tasks at once.
>>
>> For the record, we've studied this several times and have always
>> concluded that hidden synchronization is dangerous. That is,
>> synchronization should be explicit. Beyond that, it is impossible to come
>> up with a reasonable definition of what should be locked -- it really
>> depends on the use of the containers.
>
> I agree with this, but I think the OP was implying that you needed
> locking even for read-only access of Ada.Containers from multiple
> tasks; is that true? I don't see why it should be; each task declares
> its own cursors, which don't interfere with each other.
I think that the downward closure subprograms update some flags inside the
container. E.g., in gnat doubly linked lists, within the Query_Element:
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Element : Element_Type));
Pretty read-only, it seems, but inside you find:
declare
C : List renames Position.Container.all'Unrestricted_Access.all;
B : Natural renames C.Busy;
L : Natural renames C.Lock;
begin
B := B + 1;
L := L + 1;
(...)
So, basically, yes, even certain read-only uses are not thread-safe (Element
would be, at least in gnat implementation).
Never though of this before, but even wrapping a call to that in a protected
function would be dangerous, since protected functions are concurrent? And
that's a procedure with only "in" arguments, which would be callable from
such a function.
Am I right here?
next prev parent reply other threads:[~2010-02-25 14:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-21 22:09 Status of AdaCL: Ada Class Library Michael R
2010-02-22 1:51 ` Björn Persson
2010-02-22 2:07 ` Michael R
2010-02-24 19:56 ` Martin Krischik
2010-02-24 23:48 ` Randy Brukardt
2010-02-25 9:22 ` Georg Bauhaus
2010-02-25 12:23 ` Stephen Leake
2010-02-25 14:16 ` Alex R. Mosteo [this message]
2010-02-25 20:19 ` sjw
2010-02-24 19:54 ` Martin Krischik
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox