diff options
author | Simon Marlow <simonmar@microsoft.com> | 2006-06-16 11:19:37 +0000 |
---|---|---|
committer | Simon Marlow <simonmar@microsoft.com> | 2006-06-16 11:19:37 +0000 |
commit | 9c4abbc0c2d4373eb7c63b1110821dfcb0077661 (patch) | |
tree | 050653f5b7f509584168f3f34111ba310f77046b /rts/STM.c | |
parent | 135a717c69397ab2f575191254f71faf805042de (diff) | |
download | haskell-9c4abbc0c2d4373eb7c63b1110821dfcb0077661.tar.gz |
add STM support to the new throwTo mechanism
Diffstat (limited to 'rts/STM.c')
-rw-r--r-- | rts/STM.c | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -328,15 +328,21 @@ static void park_tso(StgTSO *tso) { } static void unpark_tso(Capability *cap, StgTSO *tso) { - // We will continue unparking threads while they remain on one of the wait - // queues: it's up to the thread itself to remove it from the wait queues - // if it decides to do so when it is scheduled. - if (tso -> why_blocked == BlockedOnSTM) { - TRACE("unpark_tso on tso=%p\n", tso); - unblockOne(cap,tso); - } else { - TRACE("spurious unpark_tso on tso=%p\n", tso); - } + // We will continue unparking threads while they remain on one of the wait + // queues: it's up to the thread itself to remove it from the wait queues + // if it decides to do so when it is scheduled. + + // Unblocking a TSO from BlockedOnSTM is done under the TSO lock, + // to avoid multiple CPUs unblocking the same TSO, and also to + // synchronise with throwTo(). + lockTSO(tso); + if (tso -> why_blocked == BlockedOnSTM) { + TRACE("unpark_tso on tso=%p\n", tso); + unblockOne(cap,tso); + } else { + TRACE("spurious unpark_tso on tso=%p\n", tso); + } + unlockTSO(tso); } static void unpark_waiters_on(Capability *cap, StgTVar *s) { |