[m-rev.] for review: fix bugs in parallel execution mechanism
Peter Wang
wangp at students.csse.unimelb.edu.au
Tue Oct 3 09:58:47 AEST 2006
Estimated hours taken: 4
Branches: main
Fix two bugs in my recent changes to the parallel execution mechanism which
showed up on Sparc/Solaris.
runtime/mercury_context.c:
runtime/mercury_context.h:
There was a problem with `MR_schedule_spark_locally' accessing the
engine base address. The register we thought contained the engine
base address has different contents after a C function call (I guess
due to register windows). Since the function is short and should be
inlined anyway, turn it into a macro.
runtime/mercury_thread.c:
In `MR_init_thread', delay a call to `MR_save_registers' until after
a context has been loaded into the engine, otherwise the program
crashes on startup.
Index: runtime/mercury_context.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_context.c,v
retrieving revision 1.48
diff -u -r1.48 mercury_context.c
--- runtime/mercury_context.c 26 Sep 2006 03:53:20 -0000 1.48
+++ runtime/mercury_context.c 2 Oct 2006 02:33:02 -0000
@@ -415,21 +415,6 @@
MR_UNLOCK(&MR_runqueue_lock, "schedule_spark_globally");
}
-void
-MR_schedule_spark_locally(MR_Spark *spark)
-{
- MR_Context *ctxt;
-
- ctxt = MR_ENGINE(MR_eng_this_context);
-
- /*
- ** Only the engine running the context is allowed to access
- ** the context's spark stack, so no locking is required here.
- */
- spark->MR_spark_next = ctxt->MR_ctxt_spark_stack;
- ctxt->MR_ctxt_spark_stack = spark;
-}
-
MR_define_extern_entry(MR_do_runnext);
Index: runtime/mercury_context.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_context.h,v
retrieving revision 1.31
diff -u -r1.31 mercury_context.h
--- runtime/mercury_context.h 26 Sep 2006 03:53:20 -0000 1.31
+++ runtime/mercury_context.h 2 Oct 2006 02:34:32 -0000
@@ -319,11 +319,6 @@
** Append the given spark onto the end of the spark queue.
*/
extern void MR_schedule_spark_globally(MR_Spark *spark);
-
-/*
-** Push the given spark onto the hot end of the context's spark stack.
-*/
-extern void MR_schedule_spark_locally(MR_Spark *spark);
#endif /* !MR_HIGHLEVEL_CODE */
#ifndef MR_HIGHLEVEL_CODE
@@ -366,6 +361,19 @@
(MR_num_idle_engines != 0 && \
MR_num_outstanding_contexts_and_sparks < MR_max_outstanding_contexts)
+ #define MR_schedule_spark_locally(spark) \
+ do { \
+ MR_Context *ssl_ctxt; \
+ \
+ /* \
+ ** Only the engine running the context is allowed to access \
+ ** the context's spark stack, so no locking is required here. \
+ */ \
+ ssl_ctxt = MR_ENGINE(MR_eng_this_context); \
+ spark->MR_spark_next = ssl_ctxt->MR_ctxt_spark_stack; \
+ ssl_ctxt->MR_ctxt_spark_stack = spark; \
+ } while (0)
+
#endif /* !MR_HIGHLEVEL_CODE */
#ifndef MR_CONSERVATIVE_GC
Index: runtime/mercury_thread.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_thread.c,v
retrieving revision 1.26
diff -u -r1.26 mercury_thread.c
--- runtime/mercury_thread.c 26 Sep 2006 03:53:22 -0000 1.26
+++ runtime/mercury_thread.c 30 Sep 2006 04:09:50 -0000
@@ -106,8 +106,6 @@
#endif
MR_load_engine_regs(MR_cur_engine());
- MR_save_registers();
-
#ifdef MR_THREAD_SAFE
MR_ENGINE(MR_eng_owner_thread) = pthread_self();
#endif
@@ -129,6 +127,7 @@
MR_create_context("init_thread", NULL);
}
MR_load_context(MR_ENGINE(MR_eng_this_context));
+ MR_save_registers();
return MR_TRUE;
default:
--------------------------------------------------------------------------
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