comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Question about concurrent access to array
Date: Thu, 14 Feb 2013 13:29:47 -0800 (PST)
Date: 2013-02-14T13:29:47-08:00	[thread overview]
Message-ID: <bf027023-8b59-4d12-a077-d2e757a5a58d@googlegroups.com> (raw)
In-Reply-To: <947b0951-54e4-4a4d-bd26-760eb66390c3@googlegroups.com>

On Thursday, February 14, 2013 12:39:01 PM UTC-8, jo...@peppermind.com wrote:
> I'd like like several tasks to share an unpacked array of a definite discriminant record type.
> 
> 1.) Is this possible?

I don't see why it wouldn't be.

> 2.) Do I need any kind of synchronization if I can guarantee that every task can only write and read to a different area (different range of indices) in the array? 
> 
> Performance matters a lot in this case, which is why I would prefer not to use a protected object or any other synchronization mechanism. I can't imagine how a problem could occur if every task only accesses his own part of the array, but perhaps there is still one?

I'd use an alignment aspect (or representation clause) to make sure that the array elements are aligned on some boundary, probably based on the largest integer that your machine can deal with.  Otherwise there's the risk that two consecutive array elements that "belong" to different tasks might share part of a "word" (or something), and the code to write into an element might involve reading the entire word, modifying part of the word, then writing it back.  If you do this, then I don't see how there could be a problem.  But that doesn't mean there isn't one.

                             -- Adam



  reply	other threads:[~2013-02-14 21:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14 20:39 Question about concurrent access to array john
2013-02-14 21:29 ` Adam Beneschan [this message]
2013-02-14 21:53   ` Robert A Duff
2013-02-14 23:31     ` Adam Beneschan
2013-02-15  9:11       ` cjpsimon
2013-02-14 21:41 ` Niklas Holsti
replies disabled

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