[m-rev.] for review: thread-local mutables
Peter Wang
wangp at students.csse.unimelb.edu.au
Wed Jan 10 18:49:52 AEDT 2007
On 2007-01-10, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
>
> Hi Peter,
>
> A question ...
>
> On Wed, 10 Jan 2007, Peter Wang wrote:
>
> > Add a `thread_local_mutables' field to MR_Spark and update the
> > parallel
> > conjunction implementation to take into account thread-locals.
> > Note that setting the value of a thread-local mutable inside a
> > parallel
> > conjunction is not supported.
>
> Isn't it just a matter of ensuring that when you create a new context
> as the result of a parallel conjunction that it points to the parent's
> thread_local_mutable array rather than creating a copy of it? i.e.
> we should only make a copy of the array when the user explicitly requests
> the creation of a separate thread via spawn/3 rather than as a result
> of threads created as a result of parallel conjunctions.
I think you're right.
I was thinking, if a parallel conjunct could read from an array while
another parallel conjunct was updating the same array, we'd need to
protect the array with a mutex. But it's a rather contrived situation,
as impure goals are not allowed in parallel conjuncts:
set_var("foo", !IO),
(
set_var("bar", !IO)
&
semipure get_var(Var)
)
Var could be "foo" or "bar" here, so nobody should be writing this code
anyway :-)
Peter
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list