Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1736:a4fc9f31f925
Date: 2015-03-18 09:53 +0100
http://bitbucket.org/pypy/stmgc/changeset/a4fc9f31f925/
Log: Temporary fix? Add stm_wait_for_current_inevitable_transaction()
diff --git a/c7/stm/sync.c b/c7/stm/sync.c
--- a/c7/stm/sync.c
+++ b/c7/stm/sync.c
@@ -141,6 +141,27 @@
}
}
+void stm_wait_for_current_inevitable_transaction(void)
+{
+ long i;
+ for (i = 1; i <= NB_SEGMENTS; i++) {
+ struct stm_priv_segment_info_s *other_pseg = get_priv_segment(i);
+ if (other_pseg->transaction_state == TS_INEVITABLE) {
+ /* Asynchronously found out that there is an inevitable
+ transaction running. Wait until it signals "done",
+ then return (even if another inev transaction started
+ in the meantime).
+ */
+ s_mutex_lock();
+ if (other_pseg->transaction_state == TS_INEVITABLE)
+ cond_wait(C_INEVITABLE);
+ /*else: this inev transaction finished just now */
+ s_mutex_unlock();
+ break;
+ }
+ }
+}
+
static bool acquire_thread_segment(stm_thread_local_t *tl)
{
/* This function acquires a segment for the currently running thread,
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -332,6 +332,10 @@
void stm_start_inevitable_transaction(stm_thread_local_t *tl);
void stm_commit_transaction(void);
+/* Temporary fix? Call this outside a transaction. If there is an
+ inevitable transaction running somewhere else, wait until it finishes. */
+void stm_wait_for_current_inevitable_transaction(void);
+
/* Abort the currently running transaction. This function never
returns: it jumps back to the stm_start_transaction(). */
void stm_abort_transaction(void) __attribute__((noreturn));
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit