Author: Remi Meier <[email protected]>
Branch: use-gcc
Changeset: r1900:36aff8ee0d87
Date: 2015-07-29 11:40 +0200
http://bitbucket.org/pypy/stmgc/changeset/36aff8ee0d87/
Log: finally! make sure a thread has its previous transaction committed
before starting another one
diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -615,7 +615,8 @@
new = _create_commit_log_entry();
if (STM_PSEGMENT->transaction_state == TS_INEVITABLE) {
- assert(_stm_detached_inevitable_from_thread == 0); /* running it */
+ assert(_stm_detached_inevitable_from_thread == 0 /* running it */
+ || _stm_detached_inevitable_from_thread == -1); /* committing
external */
old = STM_PSEGMENT->last_commit_log_entry;
new->rev_num = old->rev_num + 1;
@@ -1336,6 +1337,14 @@
push_large_overflow_objects_to_other_segments();
/* push before validate. otherwise they are reachable too early */
+
+ /* before releasing _stm_detached_inevitable_from_thread, perform
+ the commit. Otherwise, the same thread whose (inev) transaction we try
+ to commit here may start a new one in another segment *but* w/o
+ the committed data from its previous inev transaction. */
+ bool was_inev = STM_PSEGMENT->transaction_state == TS_INEVITABLE;
+ _validate_and_add_to_commit_log();
+
if (external) {
/* from this point on, unlink the original 'stm_thread_local_t *'
from its segment. Better do it as soon as possible, because
@@ -1345,13 +1354,8 @@
write_fence();
assert(_stm_detached_inevitable_from_thread == -1);
_stm_detached_inevitable_from_thread = 0;
- } else {
- /* we certainly are not detached right now */
- assert(_stm_detached_inevitable_from_thread !=
(intptr_t)STM_SEGMENT->running_thread);
}
- bool was_inev = STM_PSEGMENT->transaction_state == TS_INEVITABLE;
- _validate_and_add_to_commit_log();
if (!was_inev) {
assert(!external);
diff --git a/c8/stm/detach.c b/c8/stm/detach.c
--- a/c8/stm/detach.c
+++ b/c8/stm/detach.c
@@ -124,6 +124,7 @@
assert(tl != old_tl);
+ // XXX: not sure if the next line is a good idea
tl->last_associated_segment_num = remote_seg_num;
ensure_gs_register(remote_seg_num);
commit_external_inevitable_transaction();
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit