[pypy-commit] stmgc c7-refactor: in-progress
arigo
noreply at buildbot.pypy.org
Sat Feb 15 21:26:39 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r741:764a83dbf7d7
Date: 2014-02-15 21:26 +0100
http://bitbucket.org/pypy/stmgc/changeset/764a83dbf7d7/
Log: in-progress
diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -153,13 +153,20 @@
void _stm_start_transaction(stm_thread_local_t *tl, stm_jmpbuf_t *jmpbuf)
{
+ mutex_lock();
+
/* GS invalid before this point! */
acquire_thread_segment(tl);
- assert(STM_SEGMENT->activity == ACT_NOT_RUNNING);
- STM_SEGMENT->activity = jmpbuf != NULL ? ACT_REGULAR : ACT_INEVITABLE;
+ assert(STM_SEGMENT->safe_point == SP_NO_TRANSACTION);
+ assert(STM_SEGMENT->transaction_state == TS_NONE);
+ STM_SEGMENT->safe_point = SP_RUNNING;
+ STM_SEGMENT->transaction_state = (jmpbuf != NULL ? TS_REGULAR
+ : TS_INEVITABLE);
STM_SEGMENT->jmpbuf_ptr = jmpbuf;
+ mutex_unlock();
+
uint8_t old_rv = STM_SEGMENT->transaction_read_version;
STM_SEGMENT->transaction_read_version = old_rv + 1;
if (UNLIKELY(old_rv == 0xff))
@@ -200,38 +207,71 @@
list_clear(STM_PSEGMENT->modified_objects);
if (conflicted) {
- struct _thread_local1_s *remote_TL = (struct _thread_local1_s *)
- REAL_ADDRESS(remote_base, _STM_TL);
- remote_TL->need_abort = 1;
+ ...; contention management again!
+ get_segment(remote_num)->transaction_state = TS_MUST_ABORT;
}
}
void stm_commit_transaction(void)
{
+ mutex_lock();
+
+ assert(STM_SEGMENT->safe_point = SP_RUNNING);
stm_thread_local_t *tl = STM_SEGMENT->running_thread;
- assert(STM_SEGMENT->activity != ACT_NOT_RUNNING);
+ switch (STM_SEGMENT->transaction_state) {
- /* cannot abort any more */
- STM_SEGMENT->jmpbuf_ptr = NULL;
+ case TS_REGULAR:
+ /* cannot abort any more */
+ STM_SEGMENT->jmpbuf_ptr = NULL;
+ break;
- ...
+ case TS_INEVITABLE:
+ //...
+ abort(); // XXX do it
+ break;
+
+ case TS_MUST_ABORT:
+ mutex_unlock();
+ stm_abort_transaction();
+
+ default:
+ assert(!"commit: bad transaction_state");
+ }
/* copy modified object versions to other threads */
push_modified_to_other_threads();
- STM_SEGMENT->activity = ACT_NOT_RUNNING;
+ release_thread_segment(tl); /* includes the cond_broadcast(); */
+ STM_SEGMENT->safe_point = SP_NO_TRANSACTION;
+ STM_SEGMENT->transaction_state = TS_NONE;
+ mutex_unlock();
- release_thread_segment(tl);
reset_all_creation_markers();
}
void stm_abort_transaction(void)
{
+ mutex_lock();
+
stm_thread_local_t *tl = STM_SEGMENT->running_thread;
stm_jmpbuf_t *jmpbuf_ptr = STM_SEGMENT->jmpbuf_ptr;
- STM_SEGMENT->need_abort = 0;
- release_thread_segment(tl);
+
+ switch (STM_SEGMENT->transaction_state) {
+ case TS_REGULAR:
+ case TS_MUST_ABORT:
+ break;
+ case TS_INEVITABLE:
+ assert(!"abort: transaction_state == TS_INEVITABLE");
+ default:
+ assert(!"abort: bad transaction_state");
+ }
+
+ release_thread_segment(tl); /* includes the cond_broadcast(); */
+ STM_SEGMENT->safe_point = SP_NO_TRANSACTION;
+ STM_SEGMENT->transaction_state = TS_NONE;
+ mutex_unlock();
+
reset_all_creation_markers();
assert(jmpbuf_ptr != NULL);
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -63,7 +63,7 @@
};
enum {
- SP_OUTSIDE=0,
+ SP_NO_TRANSACTION=0,
SP_RUNNING,
SP_SAFE_POINT,
SP_SAFE_POINT_CAN_COLLECT,
More information about the pypy-commit
mailing list