[pypy-commit] pypy stmgc-c8-gcc: import stmgc and hopefully fix the issue of tearing down a thread before really committing the running transaction
Raemi
noreply at buildbot.pypy.org
Fri Jul 24 11:14:41 CEST 2015
Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch: stmgc-c8-gcc
Changeset: r78649:188629c10d4a
Date: 2015-07-24 11:16 +0200
http://bitbucket.org/pypy/pypy/changeset/188629c10d4a/
Log: import stmgc and hopefully fix the issue of tearing down a thread
before really committing the running transaction
diff --git a/rpython/translator/stm/src_stm/revision b/rpython/translator/stm/src_stm/revision
--- a/rpython/translator/stm/src_stm/revision
+++ b/rpython/translator/stm/src_stm/revision
@@ -1,1 +1,1 @@
-088f807586c2
+a89f21f5670b+
diff --git a/rpython/translator/stm/src_stm/stm/sync.c b/rpython/translator/stm/src_stm/stm/sync.c
--- a/rpython/translator/stm/src_stm/stm/sync.c
+++ b/rpython/translator/stm/src_stm/stm/sync.c
@@ -14,7 +14,8 @@
pthread_mutex_t global_mutex;
pthread_cond_t cond[_C_TOTAL];
/* some additional pieces of global state follow */
- uint8_t in_use1[NB_SEGMENTS]; /* 1 if running a pthread, idx=0 unused */
+ uint8_t in_use1[NB_SEGMENTS]; /* 1 if running a pthread, idx=0 unused,
+ 2 if soon_finished_or_inevitable_thread_segment */
};
char reserved[192];
} sync_ctl __attribute__((aligned(64)));
diff --git a/rpython/translator/stm/src_stm/stmgc.h b/rpython/translator/stm/src_stm/stmgc.h
--- a/rpython/translator/stm/src_stm/stmgc.h
+++ b/rpython/translator/stm/src_stm/stmgc.h
@@ -437,6 +437,10 @@
stm_enter_transactional_zone() and stm_leave_transactional_zone()
preserve the value of errno.
+
+ stm_leave_transactional_zone_final() commits the transaction
+ unconditionally and allows the caller to teardown the whole
+ thread (unregister thread local, etc.).
*/
#ifdef STM_DEBUGPRINT
#include <stdio.h>
@@ -468,6 +472,11 @@
_stm_leave_noninevitable_transactional_zone();
}
}
+static inline void stm_leave_transactional_zone_final(stm_thread_local_t *tl) {
+ assert(STM_SEGMENT->running_thread == tl);
+ _stm_commit_transaction();
+}
+
/* stm_force_transaction_break() is in theory equivalent to
stm_leave_transactional_zone() immediately followed by
diff --git a/rpython/translator/stm/src_stm/stmgcintf.c b/rpython/translator/stm/src_stm/stmgcintf.c
--- a/rpython/translator/stm/src_stm/stmgcintf.c
+++ b/rpython/translator/stm/src_stm/stmgcintf.c
@@ -98,16 +98,19 @@
void pypy_stm_leave_callback_call(void *rjbuf, long token)
{
- stm_leave_transactional_zone(&stm_thread_local);
- stm_rewind_jmp_leaveframe(&stm_thread_local, (rewind_jmp_buf *)rjbuf);
-
if (token == 1) {
/* if we're returning into foreign C code that was not itself
called from Python code, then we're ignoring the atomic
status and committing anyway. */
+ stm_leave_transactional_zone_final(&stm_thread_local);
+ stm_rewind_jmp_leaveframe(&stm_thread_local, (rewind_jmp_buf *)rjbuf);
+
int e = errno;
pypy_stm_unregister_thread_local();
errno = e;
+ } else {
+ stm_leave_transactional_zone(&stm_thread_local);
+ stm_rewind_jmp_leaveframe(&stm_thread_local, (rewind_jmp_buf *)rjbuf);
}
}
More information about the pypy-commit
mailing list