[m-dev.] thread safe mutable updates

Peter Wang wangp at students.csse.unimelb.edu.au
Tue Aug 15 14:36:45 AEST 2006


On 2006-08-15, Ralph Becket <rafe at csse.unimelb.edu.au> wrote:
> Julien Fischer, Monday, 14 August 2006:
> > (1) add a `thread_local' attribute that allows for (optional) thread-local
> >     mutables.
> > 
> > (2) for mutables that are truly global (and hence potentially shared
> >     between threads) add a new mutable operation `update' that allows
> >     the value of the mutable to be atomically updated.
> 
> What about (3) just require users to use a mutex to gain access to a mutable
> with transaction semantics?
> 
> I think that is cleaner than (1) or (2).

It's not a replacement for (1) though.  For example, a common thing in
the compiler is modify a global, do some analysis, then restore the
global to its original value.  To do the analysis in parallel, it needs
to have its own copy of the globals, because another thread could make
its own change to the globals during the analysis.  Without thread-local
mutables you'd need to thread the globals table throughout, which
defeats the purpose of having globals in the first place.

Peter
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list