[project @ 2003-12-15 16:43:45 by simonmar]
[ghc-hetmet.git] / ghc / rts / Capability.c
index 234962b..1d78982 100644 (file)
@@ -69,6 +69,9 @@ Condition thread_ready_cond = INIT_COND_VAR;
  * Task.startTask() uses its current value.
  */
 nat rts_n_waiting_tasks = 0;
+
+static Condition *passTarget = NULL;
+static rtsBool passingCapability = rtsFalse;
 #endif
 
 /* -----------------------------------------------------------------------------
@@ -198,10 +201,8 @@ void releaseCapability(Capability* cap
     signalCondition(&thread_ready_cond);
     startSchedulerTaskIfNecessary();  // if there is more work to be done,
                                      // we'll need a new thread
-  }
-#endif
-#ifdef RTS_SUPPORTS_THREADS
     IF_DEBUG(scheduler, sched_belch("worker: released capability"));
+  }
 #endif
   return;
 }
@@ -245,7 +246,7 @@ grabReturnCapability(Mutex* pMutex, Capability** pCap)
   IF_DEBUG(scheduler, 
           sched_belch("worker: returning; workers waiting: %d",
                       rts_n_waiting_workers));
-  if ( noCapabilities() ) {
+  if ( noCapabilities() || passingCapability ) {
     rts_n_waiting_workers++;
     wakeBlockedWorkerThread();
     context_switch = 1;        // make sure it's our turn soon
@@ -316,9 +317,6 @@ yieldToReturningWorker(Mutex* pMutex, Capability** pCap, Condition* pThreadCond)
  * Post-condition: pMutex is held and *pCap is held by the current thread
  */
  
-static Condition *passTarget = NULL;
-static rtsBool passingCapability = rtsFalse;
 void 
 waitForWorkCapability(Mutex* pMutex, Capability** pCap, Condition* pThreadCond)
 {