[pypy-commit] pypy stm: In-progress
arigo
noreply at buildbot.pypy.org
Thu Nov 3 18:19:31 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r48707:497d967a02c3
Date: 2011-11-03 18:19 +0100
http://bitbucket.org/pypy/pypy/changeset/497d967a02c3/
Log: In-progress
diff --git a/pypy/translator/stm/src_stm/et.c b/pypy/translator/stm/src_stm/et.c
--- a/pypy/translator/stm/src_stm/et.c
+++ b/pypy/translator/stm/src_stm/et.c
@@ -283,6 +283,12 @@
struct tx_descriptor *d = thread_descriptor;
assert(!is_inevitable(d));
d->num_aborts[reason]++;
+#ifdef RPY_STM_DEBUG_PRINT
+ PYPY_DEBUG_START("stm-abort");
+ if (PYPY_HAVE_DEBUG_PRINTS) fprintf(PYPY_DEBUG_FILE, "thread %lx aborting\n",
+ (long)pthread_self());
+ PYPY_DEBUG_STOP("stm-abort");
+#endif
tx_restart(d);
}
@@ -363,9 +369,9 @@
{
unsigned long pself = (unsigned long)pthread_self();
locked_by = 0;
- pthread_mutex_unlock(&mutex_inevitable);
if (PYPY_HAVE_DEBUG_PRINTS) fprintf(PYPY_DEBUG_FILE,
"%lx: mutex inev unlocked\n", pself);
+ pthread_mutex_unlock(&mutex_inevitable);
}
# else
# define mutex_lock() pthread_mutex_lock(&mutex_inevitable)
@@ -605,7 +611,7 @@
#ifdef RPY_STM_DEBUG_PRINT
if (PYPY_HAVE_DEBUG_PRINTS) fprintf(PYPY_DEBUG_FILE, "thread %lx starting\n",
- d->my_lock_word);
+ (long)pthread_self());
PYPY_DEBUG_STOP("stm-init");
#endif
}
@@ -633,7 +639,7 @@
num_spinloops += d->num_spinloops[i];
p += sprintf(p, "thread %lx: %d commits, %d aborts\n",
- d->my_lock_word,
+ (long)pthread_self(),
d->num_commits,
num_aborts);
diff --git a/pypy/translator/stm/test/targetdemo.py b/pypy/translator/stm/test/targetdemo.py
--- a/pypy/translator/stm/test/targetdemo.py
+++ b/pypy/translator/stm/test/targetdemo.py
@@ -19,6 +19,26 @@
newnode = Node(value)
node.next = newnode
+def check_chained_list(node):
+ seen = [0] * (LENGTH+1)
+ seen[-1] = NUM_THREADS
+ while node is not None:
+ value = node.value
+ print value
+ if not (0 <= value < LENGTH):
+ print "node.value out of bounds:", value
+ raise AssertionError
+ seen[value] += 1
+ if seen[value] > seen[value-1]:
+ print "seen[%d] = %d, seen[%d] = %d" % (value-1, seen[value-1],
+ value, seen[value])
+ raise AssertionError
+ node = node.next
+ if seen[LENGTH-1] != NUM_THREADS:
+ print "seen[LENGTH-1] != NUM_THREADS"
+ raise AssertionError
+ print "check ok!"
+
class Global:
anchor = Node(-1)
@@ -63,6 +83,7 @@
while glob.done < NUM_THREADS: # poor man's lock
time.sleep(1)
print "done sleeping."
+ check_chained_list(glob.anchor.next)
return 0
# _____ Define and setup target ___
More information about the pypy-commit
mailing list