Author: Remi Meier
Branch: c7-refactor
Changeset: r768:775ad832acb8
Date: 2014-02-18 15:53 +0100
http://bitbucket.org/pypy/stmgc/changeset/775ad832acb8/
Log: fix for contention_management calling cond_wait in tests
diff --git a/c7/stm/contention.c b/c7/stm/contention.c
--- a/c7/stm/contention.c
+++ b/c7/stm/contention.c
@@ -37,6 +37,10 @@
abort_with_mutex();
}
else if (wait) {
+#ifdef STM_TESTS
+ /* abort anyway for tests. We mustn't call cond_wait() */
+ abort_with_mutex();
+#endif
/* otherwise, we will issue a safe point and wait: */
STM_PSEGMENT->safe_point = SP_SAFE_POINT_CANNOT_COLLECT;
diff --git a/c7/test/test_random.py b/c7/test/test_random.py
--- a/c7/test/test_random.py
+++ b/c7/test/test_random.py
@@ -19,13 +19,18 @@
return "lp%d" % _root_numbering
_global_time = 0
-def contention_management(first_trs, second_trs):
- if first_trs.must_abort or second_trs.must_abort:
- return
- if first_trs.start_time < second_trs.start_time:
- second_trs.must_abort = True
+def contention_management(our_trs, other_trs, wait=False):
+ if other_trs.start_time < our_trs.start_time:
+ pass
else:
- first_trs.must_abort = True
+ other_trs.must_abort = True
+
+ if not other_trs.must_abort:
+ our_trs.must_abort = True
+ elif wait:
+ # abort anyway:
+ our_trs.must_abort = True
+
class TransactionState(object):
"""maintains read/write sets"""
@@ -168,7 +173,7 @@
continue
if other_trs.write_set & tr_state.write_set:
- contention_management(tr_state, other_trs)
+ contention_management(tr_state, other_trs, True)
def check_for_write_read_conflicts(self, tr_state):
for ts in self.thread_states:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit