Fix a bug in the new scheduler
authorSimon Marlow <marlowsd@gmail.com>
Thu, 23 Oct 2008 15:50:17 +0000 (15:50 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Thu, 23 Oct 2008 15:50:17 +0000 (15:50 +0000)
If the current thread blocks, we should yield the Capability
immediately, because the thread and hence possibly the current Task
are now owned by someone else.  This worked in the old scheduler, but
we moved where the yield happens in the new scheduler which broke it.

rts/Schedule.c

index 2e9d0dd..cc5cbb4 100644 (file)
@@ -399,6 +399,7 @@ schedule (Capability *initialCapability, Task *task)
     //     ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task);
     }
 
+  yield:
     scheduleYield(&cap,task);
     if (emptyRunQueue(cap)) continue; // look for work again
 #endif
@@ -565,7 +566,7 @@ run_thread:
        debugTrace(DEBUG_sched,
                   "--<< thread %lu (%s) stopped: blocked",
                   (unsigned long)t->id, whatNext_strs[t->what_next]);
-       continue;
+        goto yield;
     }
 #endif