comp.lang.ada
 help / color / mirror / Atom feed
From: Brad Moore <brad.moore@shaw.ca>
Subject: Re: Safety of unprotected concurrent operations on constant objects
Date: Mon, 05 May 2014 13:04:57 -0600
Date: 2014-05-05T13:04:57-06:00	[thread overview]
Message-ID: <waw9v.109142$f85.65293@fx19.iad> (raw)
In-Reply-To: <slrnlmcoqd.i0l.lithiumcat@nat.rebma.instinctive.eu>

On 04/05/2014 9:57 AM, Natasha Kerensikova wrote:
> On 2014-05-04, sbelmont700@gmail.com <sbelmont700@gmail.com> wrote:
>> On Sunday, May 4, 2014 3:46:00 AM UTC-4, Natasha Kerensikova wrote:
>>>
>>> So I guess to correctly frame it as a question, that would be: how can I
>>>
>>> have a map capable of concurrent reads with minimal wheel reinvention?
>>>
>>
>> You really can't.  You can either reinvent the wheel in your own
>> task-safe manner,
>
> I find it extremely hard to believe that there is no such wheel existing
> out there. Standard containers and Booch components might not fit the
> particular requirements, but I would bet there are some existing container
> implementations that fit.

I believe as long as the use of the container involves only read 
operations (functions with in parameters), it should be safe to use 
concurrently. Yes, these read operations typically involve modifying the 
container (to implement tamper checking), but is done in such a
way to allow safe concurrent access (at least in the implementations I 
have tried).

If done carefully, concurrent write operations on a container are also 
possible.
For example, I can provide an example in GNAT of incrementing all 
elements in an integer vector container with parallel execution, without 
any added protection or synchronization. Each worker is only updating 
elements in its assigned range of the vector, via Replace_Element. In 
the GNAT implementation, Replace_Element doesn't
set any tampering flags. It only checks for tampering, which might 
happen if another call such as Iterate was executed concurrently.
Since the only call happening during the parallel execution is 
Replace_Element, it works.

That being said, I didn't have any luck finding wording in the RM that
guarantees safe concurrent use of a constant object of a 
language-defined container object. While it likely is safe to do so, if you
are looking for a guarantee, the RM does not appear to provide one 
currently. It might be that this clarification could be added to the RM 
relatively easily, provided that implementers agree that such a 
clarification wouldn't cause too much of an implementation burden.


>
>> or assume-the-worst about the standard map and surround it with a
>> mutex.  Though, as was said, the split-seconds you would burn on the
>> mutex would be negligible when compared to the network delay of
>> supplying the results.
>
> How would you "surround it with a mutex"? Do you mean a procedure in a
> procted object, or some other scheme I'm not familiar with?
>
> However, if I start assuming the worst about standard containers, I
> might soon slip down the slope towards assuming the worst about all
> others standard features. There is nothing in the ARM that prevents tag
> checks or dispatching from being implemented through a splay tree or
> some other concurrent-read-unsafe mechanism, is there? Should I mutex
> those too then?
>



  parent reply	other threads:[~2014-05-05 19:04 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-02  8:42 Safety of unprotected concurrent operations on constant objects Natasha Kerensikova
2014-05-03 13:43 ` sbelmont700
2014-05-03 20:54   ` Natasha Kerensikova
2014-05-03 21:40     ` Simon Wright
2014-05-04  0:28       ` Jeffrey Carter
2014-05-04  7:46         ` Natasha Kerensikova
2014-05-04  8:06           ` Dmitry A. Kazakov
2014-05-04 15:18           ` sbelmont700
2014-05-04 15:57             ` Natasha Kerensikova
2014-05-04 18:30               ` sbelmont700
2014-05-04 19:34                 ` Dmitry A. Kazakov
2014-05-05 19:04               ` Brad Moore [this message]
2014-05-05 21:23                 ` Brad Moore
2014-05-04 21:44                   ` Shark8
2014-05-05  8:39                     ` Simon Wright
2014-05-05 15:11                       ` Brad Moore
2014-05-05 16:36                         ` Dmitry A. Kazakov
2014-05-06  6:00                           ` Brad Moore
2014-05-06  8:11                             ` Dmitry A. Kazakov
2014-05-06  8:48                               ` Alejandro R. Mosteo
2014-05-06  9:49                                 ` G.B.
2014-05-06 12:19                                   ` Dmitry A. Kazakov
2014-05-06 12:58                                     ` G.B.
2014-05-06 15:00                                       ` Dmitry A. Kazakov
2014-05-06 16:24                                         ` G.B.
2014-05-06 19:14                                           ` Dmitry A. Kazakov
2014-05-07  6:49                                             ` Georg Bauhaus
2014-05-07  7:40                                               ` Dmitry A. Kazakov
2014-05-07 11:25                                                 ` G.B.
2014-05-07 12:14                                                   ` Dmitry A. Kazakov
2014-05-07 13:45                                                     ` G.B.
2014-05-07 14:08                                                       ` Dmitry A. Kazakov
2014-05-07 17:45                                                   ` Simon Wright
2014-05-07 18:28                                                     ` Georg Bauhaus
2014-05-07  4:59                                         ` J-P. Rosen
2014-05-07  7:30                                           ` Dmitry A. Kazakov
2014-05-07  8:26                                             ` J-P. Rosen
2014-05-07  9:09                                               ` Dmitry A. Kazakov
2014-05-07 11:29                                                 ` J-P. Rosen
2014-05-07 12:36                                                   ` Safety of unprotected concurrent operations on constant objects (was: Safety of unprotected concurrent operations on constant objects) Dmitry A. Kazakov
2014-05-07 14:04                               ` Safety of unprotected concurrent operations on constant objects G.B.
2014-05-08  4:12                               ` Brad Moore
2014-05-08  8:20                                 ` Dmitry A. Kazakov
2014-05-08 10:30                                   ` G.B.
2014-05-09 13:14                                   ` Brad Moore
2014-05-09 19:00                                     ` Dmitry A. Kazakov
2014-05-10 12:30                                       ` Brad Moore
2014-05-10 20:27                                         ` Dmitry A. Kazakov
2014-05-11  6:56                                           ` Brad Moore
2014-05-11 18:01                                           ` Brad Moore
2014-05-12  8:13                                             ` Dmitry A. Kazakov
2014-05-13  4:50                                               ` Brad Moore
2014-05-13  8:56                                                 ` Dmitry A. Kazakov
2014-05-13 15:01                                                   ` Brad Moore
2014-05-13 15:38                                                     ` Brad Moore
2014-05-13 16:46                                                       ` Simon Wright
2014-05-13 19:15                                                         ` Dmitry A. Kazakov
2014-05-13 16:08                                                     ` Dmitry A. Kazakov
2014-05-13 20:27                                                       ` Randy Brukardt
2014-05-14  4:30                                                         ` Shark8
2014-05-14 21:37                                                           ` Randy Brukardt
2014-05-14 21:56                                                             ` Robert A Duff
2014-05-15  1:21                                                               ` Shark8
2014-05-14 14:30                                                         ` Brad Moore
2014-05-15  8:03                                                         ` Dmitry A. Kazakov
2014-05-15 13:21                                                           ` Robert A Duff
2014-05-15 14:27                                                             ` Dmitry A. Kazakov
2014-05-15 15:53                                                               ` Robert A Duff
2014-05-15 16:30                                                                 ` Dmitry A. Kazakov
2014-10-26 17:11                                                                   ` Jacob Sparre Andersen
2014-05-08 19:52                                 ` Randy Brukardt
2014-05-06 16:22                             ` Robert A Duff
2014-05-06 19:07                               ` Dmitry A. Kazakov
2014-05-08  5:03                                 ` Brad Moore
2014-05-08 12:03                                   ` Brad Moore
2014-05-08 19:57                                     ` Randy Brukardt
2014-05-09  2:58                                       ` Brad Moore
2014-05-05 20:29                         ` Natasha Kerensikova
2014-05-08  3:41                           ` Randy Brukardt
2014-05-08  9:07                             ` Natasha Kerensikova
2014-05-08 19:35                               ` Randy Brukardt
2014-05-08  3:12                       ` Randy Brukardt
2014-05-05 22:30                     ` Brad Moore
2014-05-04 16:04             ` Peter Chapin
2014-05-04 18:07               ` Natasha Kerensikova
2014-05-04 18:55           ` Jeffrey Carter
2014-05-04 19:36             ` Simon Wright
2014-05-04 20:29               ` Jeffrey Carter
2014-05-05 22:46             ` Brad Moore
2014-05-04 20:25           ` Shark8
2014-05-04 23:33             ` sbelmont700
2014-05-05  7:38             ` Dmitry A. Kazakov
2014-05-08  3:45               ` Randy Brukardt
2014-05-08  3:19 ` Randy Brukardt
replies disabled

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