* Task.startTask() uses its current value.
*/
nat rts_n_waiting_tasks = 0;
+
+static Condition *passTarget = NULL;
+static rtsBool passingCapability = rtsFalse;
#endif
/* -----------------------------------------------------------------------------
free_capabilities = (*cap)->link;
rts_n_free_capabilities--;
#endif
-#ifdef RTS_SUPPORTS_THREADS
- IF_DEBUG(scheduler, sched_belch("worker: got capability"));
-#endif
+ IF_DEBUG(scheduler, sched_belch("worker: got capability"));
}
/*
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;
}
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
* 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)
{
#ifdef SMP
#error SMP version not implemented
#endif
+ ASSERT(rts_n_free_capabilities == 0);
rts_n_free_capabilities = 1;
signalCondition(pTargetThreadCond);
passTarget = pTargetThreadCond;