-wakeupThreadOnCapability (Capability *my_cap,
- Capability *other_cap,
- StgTSO *tso)
-{
- ACQUIRE_LOCK(&other_cap->lock);
-
- // ASSUMES: cap->lock is held (asserted in wakeupThreadOnCapability)
- if (tso->bound) {
- ASSERT(tso->bound->cap == tso->cap);
- tso->bound->cap = other_cap;
- }
- tso->cap = other_cap;
-
- ASSERT(tso->bound ? tso->bound->cap == other_cap : 1);
-
- if (other_cap->running_task == NULL) {
- // nobody is running this Capability, we can add our thread
- // directly onto the run queue and start up a Task to run it.
-
- other_cap->running_task = myTask();
- // precond for releaseCapability_() and appendToRunQueue()
-
- appendToRunQueue(other_cap,tso);
-
- trace(TRACE_sched, "resuming capability %d", other_cap->no);
- releaseCapability_(other_cap,rtsFalse);
- } else {
- appendToWakeupQueue(my_cap,other_cap,tso);
- other_cap->context_switch = 1;
- // someone is running on this Capability, so it cannot be
- // freed without first checking the wakeup queue (see
- // releaseCapability_).
- }
-
- RELEASE_LOCK(&other_cap->lock);
-}
-
-/* ----------------------------------------------------------------------------
- * prodCapabilities
- *
- * Used to indicate that the interrupted flag is now set, or some
- * other global condition that might require waking up a Task on each
- * Capability.
- * ------------------------------------------------------------------------- */
-
-static void
-prodCapabilities(rtsBool all)