Author: Tobias Weber <tobias_webe...@gmx.de> Branch: c8-tcp-style-trx-length Changeset: r2085:e0f9b83d9771 Date: 2017-07-04 12:49 +0200 http://bitbucket.org/pypy/stmgc/changeset/e0f9b83d9771/
Log: Merge minor fixes to commit signalling diff --git a/c8/stm/core.c b/c8/stm/core.c --- a/c8/stm/core.c +++ b/c8/stm/core.c @@ -1638,7 +1638,7 @@ void _stm_become_inevitable(const char *msg) { - int num_waits = 0; + int num_waits = NB_SEGMENTS; //0; // TODO try disable timing_become_inevitable(); @@ -1655,8 +1655,6 @@ stm_abort_transaction(); /* is already inevitable, abort */ #endif - bool timed_out = false; - s_mutex_lock(); if (any_soon_finished_or_inevitable_thread_segment() && !safe_point_requested()) { @@ -1665,36 +1663,33 @@ /* wait until C_SEGMENT_FREE_OR_SAFE_POINT_REQ is signalled */ EMIT_WAIT(STM_WAIT_OTHER_INEVITABLE); - if (!cond_wait_timeout(C_SEGMENT_FREE_OR_SAFE_POINT_REQ, - 0.000054321)) - timed_out = true; + if (!cond_wait_timeout(C_SEGMENT_FREE_OR_SAFE_POINT_REQ, 0.00001)) { + s_mutex_unlock(); + /* try to detach another inevitable transaction, but + only after waiting a bit. This is necessary to avoid + deadlocks in some situations, which are hopefully + not too common. We don't want two threads constantly + detaching each other. */ + intptr_t detached = fetch_detached_transaction(); + if (detached != 0) { + EMIT_WAIT_DONE(); + commit_fetched_detached_transaction(detached); + } + goto retry_from_start; + } + num_waits++; } s_mutex_unlock(); - - if (timed_out) { - /* try to detach another inevitable transaction, but - only after waiting a bit. This is necessary to avoid - deadlocks in some situations, which are hopefully - not too common. We don't want two threads constantly - detaching each other. */ - intptr_t detached = fetch_detached_transaction(); - if (detached != 0) { - EMIT_WAIT_DONE(); - commit_fetched_detached_transaction(detached); - } + goto retry_from_start; + } else { + EMIT_WAIT_DONE(); + if (!_validate_and_turn_inevitable()) { + goto retry_from_start; } - else { - num_waits++; - } - goto retry_from_start; } - EMIT_WAIT_DONE(); - if (!_validate_and_turn_inevitable()) - goto retry_from_start; } - else { - if (!_validate_and_turn_inevitable()) - return; + else if (!_validate_and_turn_inevitable()) { + return; } /* There may be a concurrent commit of a detached Tx going on. diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -549,8 +549,10 @@ pseg->pub.nursery_current = (stm_char *)_stm_nursery_start; pseg->pub.nursery_mark -= nursery_used; - if (pseg->commit_if_not_atomic && pseg->pub.running_thread->self_or_0_if_atomic != 0) { - // not atomic and commit signalled by waiting thread: commit immediately + if (pseg->commit_if_not_atomic + && pseg->transaction_state == TS_INEVITABLE + && pseg->pub.running_thread->self_or_0_if_atomic != 0) { + // transaction is inevitable, not atomic, and commit has been signalled by waiting thread: commit immediately pseg->pub.nursery_mark = 0; } _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit