[pypy-commit] stmgc default: Move to the test runner a general fix for thread-order problems.
arigo
noreply at buildbot.pypy.org
Mon Jun 17 14:22:53 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r169:88201fa26d98
Date: 2013-06-17 14:17 +0200
http://bitbucket.org/pypy/stmgc/changeset/88201fa26d98/
Log: Move to the test runner a general fix for thread-order problems.
diff --git a/c4/test/support.py b/c4/test/support.py
--- a/c4/test/support.py
+++ b/c4/test/support.py
@@ -308,11 +308,15 @@
self.parallel_locks = (thread.allocate_lock(), thread.allocate_lock())
self.parallel_locks[0].acquire()
self.resulting_exception = None
+ self.start_locks = []
+ for fn in fns:
+ self.start_locks.append(thread.allocate_lock())
+ self.start_locks[-1].acquire()
locks = []
- for fn in fns:
+ for i, fn in enumerate(fns):
lck = thread.allocate_lock()
lck.acquire()
- thread.start_new_thread(self.run, (fn, lck))
+ thread.start_new_thread(self.run, (fn, lck, i))
locks.append(lck)
for lck in locks:
lck.acquire()
@@ -322,11 +326,17 @@
exc, val, tb = self.resulting_exception
raise exc, val, tb
- def run(self, fn, lck):
+ def run(self, fn, lck, i):
try:
try:
lib.stm_initialize_and_set_max_abort(self.max_aborts)
try:
+ # wait here until all threads reach this point
+ self.start_locks[i].release()
+ for _lck1 in self.start_locks:
+ acquire_lock(_lck1)
+ _lck1.release()
+ #
fn(self)
finally:
lib.stm_finalize()
diff --git a/c4/test/test_et.py b/c4/test/test_et.py
--- a/c4/test/test_et.py
+++ b/c4/test/test_et.py
@@ -407,10 +407,8 @@
assert classify(follow_revision(p)) == "stub"
assert p1.h_revision & 1
r.set(2)
- r.wait(3) # wait until the other thread really starts
def f2(r):
r.wait(2)
- r.set(3)
p2 = lib.stm_read_barrier(p) # steals
assert classify(p2) == "public"
q2 = lib.getptr(p2, 0)
More information about the pypy-commit
mailing list