diff: fix early release of stm lock

View: New views
2 Messages — Rating Filter:   Alert me  

diff: fix early release of stm lock

by Peter Wang-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
Administrative Queries: owner-mercury-reviews@...
Subscriptions:          mercury-reviews-request@...
--------------------------------------------------------------------------

Re: diff: fix early release of stm lock

by Julien Fischer-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Fri, 30 Oct 2009, Peter Wang wrote:

> 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.

You actually mean transaction variable rather than log at the end there.
The condition vars are attached to the former since other threads
require access to them as well.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews@...
Administrative Queries: owner-mercury-reviews@...
Subscriptions:          mercury-reviews-request@...
--------------------------------------------------------------------------