[m-rev.] for review: bug fixes for threads

Peter Wang wangp at students.csse.unimelb.edu.au
Fri Mar 2 13:51:37 AEDT 2007


On 2007-02-20, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> >
> >runtime/mercury_context.c:
> >runtime/mercury_context.h:
> >runtime/mercury_engine.c:
> >runtime/mercury_engine.h:
...
> >
> >	Add a comment that none of this is implemented for grades not using 
> >	gcc
> >	non-local gotos (nor was it implemented before).
> 
> Out of curiosity is there some particular difficulty in implementing it
> in the absence of non-local gotos?

Probably no great difficulty.

> >Index: runtime/mercury_engine.c
> >===================================================================
> >RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.c,v
> >retrieving revision 1.55
> >diff -u -r1.55 mercury_engine.c
> >--- runtime/mercury_engine.c	11 Dec 2006 03:03:13 -0000	1.55
> >+++ runtime/mercury_engine.c	16 Feb 2007 04:07:40 -0000
> >@@ -37,6 +37,7 @@
> >
> >  #ifndef MR_USE_GCC_NONLOCAL_GOTOS
> >    static MR_Code  *engine_done(void);
> >+    static MR_Code  *engine_done_2(void);
> >    static MR_Code  *engine_init_registers(void);
> >  #endif
> 
> I don't understand the distinction between engine_done and
> engine_done_2.
> 

engine_done can now be entered while the context is running on the wrong
engine (thread).  If it turns out to be the case, then we suspend the
context and reschedule it so that it will resume in engine_done_2 and be
run on the correct engine.  So engine_done_2 will always be run on the
engine which started the C->Mercury call, and engine_done ensures that
is the case.

> >Index: runtime/mercury_thread.c
> >===================================================================
> >RCS file: /home/mercury1/repository/mercury/runtime/mercury_thread.c,v
> >retrieving revision 1.30
> >diff -u -r1.30 mercury_thread.c
> >--- runtime/mercury_thread.c	16 Jan 2007 23:45:05 -0000	1.30
> >+++ runtime/mercury_thread.c	15 Feb 2007 10:37:37 -0000
> >@@ -49,7 +49,9 @@
> >
> >    thread = MR_GC_NEW(MercuryThread);
> >    pthread_attr_init(&attrs);
> >+    pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
> 
> It's probably worth adding a comment about why it is okay to create
> detached threads here (e.g. essentially what was in the log message for
> this file.)

Okay.

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