[m-dev.] Globals and concurrency

Peter Wang wangp at students.csse.unimelb.edu.au
Tue Aug 1 18:46:43 AEST 2006


On 2006-08-01, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> >If io globals are not context-specific, then there should be a locking
> >mechanism, otherwise code like:
> >   io.get_globals(Globals0, !IO),
> >   foo(Globals0, Globals),
> >   io.set_globals(Globals, !IO),
> >
> >is not thread-safe.
> 
> I presume the problem here is that the existing locking mechanisms are
> in the wrong spot, i.e they are attached to the access preds rather than
> the global (so while two threads cannot simultaneously call io.get_globals,
> two threads could simultaneously call io.get_globals and io.set_globals)?

Yes.

> 
> It would seem that mutable declarations also have this problem then.

Yes.

> 
> >Also, what about moving (some of) the concurrency library into the
> >standard library?
> 
> I'm not opposed to doing that in principle - but I'd like to see a little
> more detail first.

At a minimum, I think concurrency.spawn and concurrency.mvar are
required.

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