[project @ 2005-10-26 15:20:59 by simonmar]
[ghc-hetmet.git] / ghc / rts / Schedule.c
index fe50cd4..7af3ab5 100644 (file)
@@ -408,6 +408,12 @@ schedule (Capability *initialCapability, Task *task)
        deleteRunQueue(cap);
        if (shutting_down_scheduler) {
            IF_DEBUG(scheduler, sched_belch("shutting down"));
+           // If we are a worker, just exit.  If we're a bound thread
+           // then we will exit below when we've removed our TSO from
+           // the run queue.
+           if (task->tso == NULL) {
+               return cap;
+           }
        } else {
            IF_DEBUG(scheduler, sched_belch("interrupted"));
        }
@@ -1928,6 +1934,7 @@ forkProcess(HsStablePtr *entry
     if (pid) { // parent
        
        // just return the pid
+       rts_unlock(cap);
        return pid;
        
     } else { // child
@@ -2456,6 +2463,8 @@ scheduleWaitThread (StgTSO* tso, /*[out]*/HaskellObj* ret, Capability *cap)
     cap = schedule(cap,task);
 
     ASSERT(task->stat != NoStatus);
+    ASSERT(cap->running_task == task);
+    ASSERT(task->cap == cap);
 
     IF_DEBUG(scheduler, sched_belch("bound thread (%d) finished", task->tso->id));
     return cap;