[pypy-commit] stmgc c8-gil-like: fixfix
arigo
noreply at buildbot.pypy.org
Thu Jun 11 12:42:01 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: c8-gil-like
Changeset: r1804:ff025e03931c
Date: 2015-06-11 12:42 +0200
http://bitbucket.org/pypy/stmgc/changeset/ff025e03931c/
Log: fixfix
diff --git a/c8/stm/core.h b/c8/stm/core.h
--- a/c8/stm/core.h
+++ b/c8/stm/core.h
@@ -162,6 +162,7 @@
#ifdef STM_TESTS
SP_WAIT_FOR_OTHER_THREAD,
#endif
+ SP_COMMIT_OTHER_DETACHED,
};
enum /* transaction_state */ {
diff --git a/c8/stm/detach.c b/c8/stm/detach.c
--- a/c8/stm/detach.c
+++ b/c8/stm/detach.c
@@ -144,17 +144,32 @@
probably belonging to an unrelated thread. We fetched it,
which means that nobody else can concurrently fetch it now, but
everybody will see that there is still a concurrent inevitable
- transaction. This should guarantee there are not race
+ transaction. This should guarantee there are no race
conditions.
*/
+ int mysegnum = STM_SEGMENT->segment_num;
int segnum = ((stm_thread_local_t *)old)->last_associated_segment_num;
dprintf(("commit_fetched_detached_transaction from seg %d\n", segnum));
assert(segnum > 0);
- int mysegnum = STM_SEGMENT->segment_num;
- ensure_gs_register(segnum);
+ if (segnum != mysegnum) {
+ s_mutex_lock();
+ assert(STM_PSEGMENT->safe_point == SP_RUNNING);
+ STM_PSEGMENT->safe_point = SP_COMMIT_OTHER_DETACHED;
+ s_mutex_unlock();
+
+ set_gs_register(get_segment_base(segnum));
+ }
commit_external_inevitable_transaction();
- ensure_gs_register(mysegnum);
+
+ if (segnum != mysegnum) {
+ set_gs_register(get_segment_base(mysegnum));
+
+ s_mutex_lock();
+ assert(STM_PSEGMENT->safe_point == SP_COMMIT_OTHER_DETACHED);
+ STM_PSEGMENT->safe_point = SP_RUNNING;
+ s_mutex_unlock();
+ }
}
static void commit_detached_transaction_if_from(stm_thread_local_t *tl)
diff --git a/c8/stm/sync.c b/c8/stm/sync.c
--- a/c8/stm/sync.c
+++ b/c8/stm/sync.c
@@ -329,6 +329,7 @@
}
assert(!pause_signalled);
pause_signalled = true;
+ dprintf(("request to pause\n"));
}
static inline long count_other_threads_sp_running(void)
@@ -363,6 +364,7 @@
if (get_segment(i)->nursery_end == NSE_SIGPAUSE)
get_segment(i)->nursery_end = NURSERY_END;
}
+ dprintf(("request removed\n"));
cond_broadcast(C_REQUEST_REMOVED);
}
@@ -380,6 +382,7 @@
if (STM_SEGMENT->nursery_end == NURSERY_END)
break; /* no safe point requested */
+ dprintf(("enter safe point\n"));
assert(STM_SEGMENT->nursery_end == NSE_SIGPAUSE);
assert(pause_signalled);
@@ -394,6 +397,7 @@
cond_wait(C_REQUEST_REMOVED);
STM_PSEGMENT->safe_point = SP_RUNNING;
timing_event(STM_SEGMENT->running_thread, STM_WAIT_DONE);
+ dprintf(("left safe point\n"));
}
}
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -428,7 +428,8 @@
}
else {
_stm_reattach_transaction(old, tl);
- assert(_stm_detached_inevitable_from_thread == 0);
+ /* _stm_detached_inevitable_from_thread should be 0 here, but
+ it can already have been changed from a parallel thread */
}
}
static inline void stm_leave_transactional_zone(stm_thread_local_t *tl) {
More information about the pypy-commit
mailing list