X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2FSTM.c;h=b9be955f55dfb5e8ebb94ee03e40ec03d1b40f3f;hp=c271a25d3cf6bbfe0c2ccd6729a7e7956bf1fe76;hb=9ecd4a3e69829f4c4ca6207043256cd40146556d;hpb=067ec969bb0bdc4c88582e53b040fa2925cbcc56 diff --git a/rts/STM.c b/rts/STM.c index c271a25..b9be955 100644 --- a/rts/STM.c +++ b/rts/STM.c @@ -306,7 +306,7 @@ static StgClosure *lock_tvar(StgTRecHeader *trec, do { do { result = s -> current_value; - } while (GET_INFO(result) == &stg_TREC_HEADER_info); + } while (GET_INFO(UNTAG_CLOSURE(result)) == &stg_TREC_HEADER_info); } while (cas((void *)&(s -> current_value), (StgWord)result, (StgWord)trec) != (StgWord)result); return result; @@ -388,10 +388,18 @@ static void unpark_tso(Capability *cap, StgTSO *tso) { static void unpark_waiters_on(Capability *cap, StgTVar *s) { StgTVarWatchQueue *q; + StgTVarWatchQueue *trail; TRACE("unpark_waiters_on tvar=%p", s); - for (q = s -> first_watch_queue_entry; - q != END_STM_WATCH_QUEUE; + // unblock TSOs in reverse order, to be a bit fairer (#2319) + for (q = s -> first_watch_queue_entry, trail = q; + q != END_STM_WATCH_QUEUE; q = q -> next_queue_entry) { + trail = q; + } + q = trail; + for (; + q != END_STM_WATCH_QUEUE; + q = q -> prev_queue_entry) { if (watcher_is_tso(q)) { unpark_tso(cap, (StgTSO *)(q -> closure)); } @@ -1565,7 +1573,7 @@ static StgClosure *read_current_value(StgTRecHeader *trec STG_UNUSED, StgTVar *t result = tvar -> current_value; #if defined(STM_FG_LOCKS) - while (GET_INFO(result) == &stg_TREC_HEADER_info) { + while (GET_INFO(UNTAG_CLOSURE(result)) == &stg_TREC_HEADER_info) { TRACE("%p : read_current_value(%p) saw %p", trec, tvar, result); result = tvar -> current_value; }