Author: Armin Rigo <[email protected]>
Branch: c7-refactor
Changeset: r864:30bde5ed0833
Date: 2014-02-25 17:16 +0100
http://bitbucket.org/pypy/stmgc/changeset/30bde5ed0833/
Log: Add *_no_abort() versions for cond_wait() and mutex_lock(). Needed
if we don't have our own segment so far.
diff --git a/c7/demo/demo_random.c b/c7/demo/demo_random.c
--- a/c7/demo/demo_random.c
+++ b/c7/demo/demo_random.c
@@ -7,7 +7,7 @@
#include "stmgc.h"
-#define NUMTHREADS 2
+#define NUMTHREADS 3
#define STEPS_PER_THREAD 5000
#define THREAD_STARTS 100 // how many restarts of threads
#define SHARED_ROOTS 3
diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -149,7 +149,7 @@
void _stm_start_transaction(stm_thread_local_t *tl, stm_jmpbuf_t *jmpbuf)
{
- mutex_lock();
+ mutex_lock_no_abort();
/* GS invalid before this point! */
acquire_thread_segment(tl);
diff --git a/c7/stm/fprintcolor.c b/c7/stm/fprintcolor.c
--- a/c7/stm/fprintcolor.c
+++ b/c7/stm/fprintcolor.c
@@ -13,7 +13,8 @@
char buffer[2048];
va_list ap;
int result;
- int size = (int)sprintf(buffer, "\033[%dm", dprintfcolor());
+ int size = (int)sprintf(buffer, "\033[%dm[%lx]", dprintfcolor(),
+ (long)pthread_self());
assert(size >= 0);
va_start(ap, format);
diff --git a/c7/stm/sync.c b/c7/stm/sync.c
--- a/c7/stm/sync.c
+++ b/c7/stm/sync.c
@@ -65,13 +65,17 @@
stm_fatalerror("syscall(arch_prctl, ARCH_SET_GS): %m\n");
}
-static inline void mutex_lock(void)
+static inline void mutex_lock_no_abort(void)
{
assert(!_has_mutex_here);
if (UNLIKELY(pthread_mutex_lock(&sync_ctl.global_mutex) != 0))
stm_fatalerror("pthread_mutex_lock: %m\n");
assert((_has_mutex_here = true, 1));
+}
+static inline void mutex_lock(void)
+{
+ mutex_lock_no_abort();
if (STM_PSEGMENT->transaction_state == TS_MUST_ABORT)
abort_with_mutex();
}
@@ -87,7 +91,7 @@
assert((_has_mutex_here = false, 1));
}
-static inline void cond_wait(enum cond_type_e ctype)
+static inline void cond_wait_no_abort(enum cond_type_e ctype)
{
#ifdef STM_NO_COND_WAIT
stm_fatalerror("*** cond_wait/%d called!\n", (int)ctype);
@@ -97,7 +101,11 @@
if (UNLIKELY(pthread_cond_wait(&sync_ctl.cond[ctype],
&sync_ctl.global_mutex) != 0))
stm_fatalerror("pthread_cond_wait/%d: %m\n", (int)ctype);
+}
+static inline void cond_wait(enum cond_type_e ctype)
+{
+ cond_wait_no_abort(ctype);
if (STM_PSEGMENT->transaction_state == TS_MUST_ABORT)
abort_with_mutex();
}
@@ -148,7 +156,7 @@
/* Wait and retry. It is guaranteed that any thread releasing its
segment will do so by acquiring the mutex and calling
cond_signal(C_RELEASE_THREAD_SEGMENT). */
- cond_wait(C_RELEASE_THREAD_SEGMENT);
+ cond_wait_no_abort(C_RELEASE_THREAD_SEGMENT);
goto retry;
got_num:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit