diff options
author | Simon Marlow <marlowsd@gmail.com> | 2010-03-29 14:45:21 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2010-03-29 14:45:21 +0000 |
commit | 2726a2f10256710cc6ed80b1098cb32e121e1be7 (patch) | |
tree | 81eef196c77c6a7f4581547202e664f38cc70882 /rts/Schedule.h | |
parent | 4b7fdaa8617e1fadc6175d2400d11fa1fc062c03 (diff) | |
download | haskell-2726a2f10256710cc6ed80b1098cb32e121e1be7.tar.gz |
Move a thread to the front of the run queue when another thread blocks on it
This fixes #3838, and was made possible by the new BLACKHOLE
infrastructure. To allow reording of the run queue I had to make it
doubly-linked, which entails some extra trickiness with regard to
GC write barriers and suchlike.
Diffstat (limited to 'rts/Schedule.h')
-rw-r--r-- | rts/Schedule.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/rts/Schedule.h b/rts/Schedule.h index 0db2b1ed84..1e786ce690 100644 --- a/rts/Schedule.h +++ b/rts/Schedule.h @@ -118,8 +118,10 @@ appendToRunQueue (Capability *cap, StgTSO *tso) ASSERT(tso->_link == END_TSO_QUEUE); if (cap->run_queue_hd == END_TSO_QUEUE) { cap->run_queue_hd = tso; + tso->block_info.prev = END_TSO_QUEUE; } else { setTSOLink(cap, cap->run_queue_tl, tso); + setTSOPrev(cap, tso, cap->run_queue_tl); } cap->run_queue_tl = tso; traceEventThreadRunnable (cap, tso); @@ -135,6 +137,10 @@ EXTERN_INLINE void pushOnRunQueue (Capability *cap, StgTSO *tso) { setTSOLink(cap, tso, cap->run_queue_hd); + tso->block_info.prev = END_TSO_QUEUE; + if (cap->run_queue_hd != END_TSO_QUEUE) { + setTSOPrev(cap, cap->run_queue_hd, tso); + } cap->run_queue_hd = tso; if (cap->run_queue_tl == END_TSO_QUEUE) { cap->run_queue_tl = tso; @@ -149,6 +155,7 @@ popRunQueue (Capability *cap) StgTSO *t = cap->run_queue_hd; ASSERT(t != END_TSO_QUEUE); cap->run_queue_hd = t->_link; + cap->run_queue_hd->block_info.prev = END_TSO_QUEUE; t->_link = END_TSO_QUEUE; // no write barrier req'd if (cap->run_queue_hd == END_TSO_QUEUE) { cap->run_queue_tl = END_TSO_QUEUE; @@ -156,6 +163,8 @@ popRunQueue (Capability *cap) return t; } +extern void removeFromRunQueue (Capability *cap, StgTSO *tso); + /* Add a thread to the end of the blocked queue. */ #if !defined(THREADED_RTS) |