summaryrefslogtreecommitdiff
path: root/rts/Schedule.c
diff options
context:
space:
mode:
Diffstat (limited to 'rts/Schedule.c')
-rw-r--r--rts/Schedule.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 544b9c2115..611d70411f 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -723,7 +723,7 @@ schedulePushWork(Capability *cap USED_IF_THREADS,
if (cap != cap0 && !cap0->disabled && tryGrabCapability(cap0,task)) {
if (!emptyRunQueue(cap0)
|| cap0->n_returning_tasks != 0
- || cap0->inbox != (Message*)END_TSO_QUEUE) {
+ || !emptyInbox(cap0)) {
// it already has some work, we just grabbed it at
// the wrong moment. Or maybe it's deadlocked!
releaseCapability(cap0);
@@ -982,6 +982,7 @@ scheduleProcessInbox (Capability **pcap USED_IF_THREADS)
{
#if defined(THREADED_RTS)
Message *m, *next;
+ PutMVar *p, *pnext;
int r;
Capability *cap = *pcap;
@@ -1006,7 +1007,9 @@ scheduleProcessInbox (Capability **pcap USED_IF_THREADS)
if (r != 0) return;
m = cap->inbox;
+ p = cap->putMVars;
cap->inbox = (Message*)END_TSO_QUEUE;
+ cap->putMVars = NULL;
RELEASE_LOCK(&cap->lock);
@@ -1015,10 +1018,20 @@ scheduleProcessInbox (Capability **pcap USED_IF_THREADS)
executeMessage(cap, m);
m = next;
}
+
+ while (p != NULL) {
+ pnext = p->link;
+ performTryPutMVar(cap, (StgMVar*)deRefStablePtr(p->mvar),
+ Unit_closure);
+ freeStablePtr(p->mvar);
+ stgFree(p);
+ p = pnext;
+ }
}
#endif
}
+
/* ----------------------------------------------------------------------------
* Activate spark threads (THREADED_RTS)
* ------------------------------------------------------------------------- */