From: Simon Marlow Date: Wed, 8 Oct 2008 11:26:27 +0000 (+0000) Subject: add comments and an ASSERT_LOCK_HELD() X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=aac6f4e51b57094702ca21ea55c48c91019deed8 add comments and an ASSERT_LOCK_HELD() --- diff --git a/rts/RaiseAsync.c b/rts/RaiseAsync.c index d411c41..10d91a7 100644 --- a/rts/RaiseAsync.c +++ b/rts/RaiseAsync.c @@ -575,6 +575,12 @@ performBlockedException (Capability *cap, StgTSO *source, StgTSO *target) This is for use when we raise an exception in another thread, which may be blocked. + + Precondition: we have exclusive access to the TSO, which entails + holding a lock on the object that owns the queue, if the TSO is + blocked. e.g. if the thread is blocked on an MVar, we must hold a + lock on the MVar before calling removeFromQueues(). + This has nothing to do with the UnblockThread event in GranSim. -- HWL -------------------------------------------------------------------------- */ @@ -752,6 +758,9 @@ removeFromQueues(Capability *cap, StgTSO *tso) goto done; case BlockedOnBlackHole: + // we have exclusive access to this TSO, which implies that we + // must hold sched_mutex: + ASSERT_LOCK_HELD(&sched_mutex); removeThreadFromQueue(cap, &blackhole_queue, tso); goto done;