[m-rev.] diff: fix early release of stm lock
Peter Wang
novalazy at gmail.com
Fri Oct 30 15:57:31 AEDT 2009
Julien looked at this.
Branches: main
runtime/mercury_stm.c:
In MR_STM_block_thread, on resuming execution, don't release the STM
lock until after removing the thread's condition variable from the
transaction log.
diff --git a/runtime/mercury_stm.c b/runtime/mercury_stm.c
index 85634f6..73c9efa 100644
--- a/runtime/mercury_stm.c
+++ b/runtime/mercury_stm.c
@@ -370,13 +370,14 @@ MR_STM_block_thread(MR_STM_TransLog *tlog)
fprintf(stderr, "STM BLOCKING: log <0x%.8lx>\n", (MR_Word)tlog);
#endif
MR_STM_condvar_wait(thread_condvar, &MR_STM_lock);
- MR_UNLOCK(&MR_STM_lock, "MR_STM_block_thread");
#if defined(MR_STM_DEBUG)
fprintf(stderr, "STM RESCHEDULING: log <0x%.8lx>\n", (MR_Word)tlog);
#endif
MR_STM_unwait(tlog, thread_condvar);
+ MR_UNLOCK(&MR_STM_lock, "MR_STM_block_thread");
+
MR_GC_free(thread_condvar);
#else
MR_fatal_error("Blocking thread in non-parallel grade");
--------------------------------------------------------------------------
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