1 /* ---------------------------------------------------------------------------
3 * (c) The GHC Team, 2003-2006
7 * A Capability represent the token required to execute STG code,
8 * and all the state an OS thread/task needs to run Haskell code:
9 * its STG registers, a pointer to its TSO, a nursery etc. During
10 * STG execution, a pointer to the capabilitity is kept in a
11 * register (BaseReg; actually it is a pointer to cap->r).
13 * Only in an THREADED_RTS build will there be multiple capabilities,
14 * for non-threaded builds there is only one global capability, namely
17 * --------------------------------------------------------------------------*/
19 #include "PosixSource.h"
22 #include "Capability.h"
26 #include "sm/GC.h" // for gcWorkerThread()
30 // one global capability, this is the Capability for non-threaded
31 // builds, and for +RTS -N1
32 Capability MainCapability;
34 nat n_capabilities = 0;
35 Capability *capabilities = NULL;
37 // Holds the Capability which last became free. This is used so that
38 // an in-call has a chance of quickly finding a free Capability.
39 // Maintaining a global free list of Capabilities would require global
40 // locking, so we don't do that.
41 Capability *last_free_capability = NULL;
43 /* GC indicator, in scope for the scheduler, init'ed to false */
44 volatile StgWord waiting_for_gc = 0;
46 /* Let foreign code get the current Capability -- assuming there is one!
47 * This is useful for unsafe foreign calls because they are called with
48 * the current Capability held, but they are not passed it. For example,
49 * see see the integer-gmp package which calls allocateLocal() in its
50 * stgAllocForGMP() function (which gets called by gmp functions).
52 Capability * rts_unsafeGetMyCapability (void)
54 #if defined(THREADED_RTS)
57 return &MainCapability;
61 #if defined(THREADED_RTS)
65 return blackholes_need_checking
66 || sched_state >= SCHED_INTERRUPTING
71 #if defined(THREADED_RTS)
73 findSpark (Capability *cap)
80 if (!emptyRunQueue(cap) || cap->returning_tasks_hd != NULL) {
81 // If there are other threads, don't try to run any new
82 // sparks: sparks might be speculative, we don't want to take
83 // resources away from the main computation.
90 // first try to get a spark from our own pool.
91 // We should be using reclaimSpark(), because it works without
92 // needing any atomic instructions:
93 // spark = reclaimSpark(cap->sparks);
94 // However, measurements show that this makes at least one benchmark
95 // slower (prsa) and doesn't affect the others.
96 spark = tryStealSpark(cap);
98 cap->sparks_converted++;
100 // Post event for running a spark from capability's own pool.
101 traceSchedEvent(cap, EVENT_RUN_SPARK, cap->r.rCurrentTSO, 0);
105 if (!emptySparkPoolCap(cap)) {
109 if (n_capabilities == 1) { return NULL; } // makes no sense...
111 debugTrace(DEBUG_sched,
112 "cap %d: Trying to steal work from other capabilities",
115 /* visit cap.s 0..n-1 in sequence until a theft succeeds. We could
116 start at a random place instead of 0 as well. */
117 for ( i=0 ; i < n_capabilities ; i++ ) {
118 robbed = &capabilities[i];
119 if (cap == robbed) // ourselves...
122 if (emptySparkPoolCap(robbed)) // nothing to steal here
125 spark = tryStealSpark(robbed);
126 if (spark == NULL && !emptySparkPoolCap(robbed)) {
127 // we conflicted with another thread while trying to steal;
133 cap->sparks_converted++;
135 traceSchedEvent(cap, EVENT_STEAL_SPARK,
136 cap->r.rCurrentTSO, robbed->no);
140 // otherwise: no success, try next one
144 debugTrace(DEBUG_sched, "No sparks stolen");
148 // Returns True if any spark pool is non-empty at this moment in time
149 // The result is only valid for an instant, of course, so in a sense
150 // is immediately invalid, and should not be relied upon for
157 for (i=0; i < n_capabilities; i++) {
158 if (!emptySparkPoolCap(&capabilities[i])) {
166 /* -----------------------------------------------------------------------------
167 * Manage the returning_tasks lists.
169 * These functions require cap->lock
170 * -------------------------------------------------------------------------- */
172 #if defined(THREADED_RTS)
174 newReturningTask (Capability *cap, Task *task)
176 ASSERT_LOCK_HELD(&cap->lock);
177 ASSERT(task->return_link == NULL);
178 if (cap->returning_tasks_hd) {
179 ASSERT(cap->returning_tasks_tl->return_link == NULL);
180 cap->returning_tasks_tl->return_link = task;
182 cap->returning_tasks_hd = task;
184 cap->returning_tasks_tl = task;
188 popReturningTask (Capability *cap)
190 ASSERT_LOCK_HELD(&cap->lock);
192 task = cap->returning_tasks_hd;
194 cap->returning_tasks_hd = task->return_link;
195 if (!cap->returning_tasks_hd) {
196 cap->returning_tasks_tl = NULL;
198 task->return_link = NULL;
203 /* ----------------------------------------------------------------------------
206 * The Capability is initially marked not free.
207 * ------------------------------------------------------------------------- */
210 initCapability( Capability *cap, nat i )
215 cap->in_haskell = rtsFalse;
216 cap->in_gc = rtsFalse;
218 cap->run_queue_hd = END_TSO_QUEUE;
219 cap->run_queue_tl = END_TSO_QUEUE;
221 #if defined(THREADED_RTS)
222 initMutex(&cap->lock);
223 cap->running_task = NULL; // indicates cap is free
224 cap->spare_workers = NULL;
225 cap->suspended_ccalling_tasks = NULL;
226 cap->returning_tasks_hd = NULL;
227 cap->returning_tasks_tl = NULL;
228 cap->wakeup_queue_hd = END_TSO_QUEUE;
229 cap->wakeup_queue_tl = END_TSO_QUEUE;
230 cap->sparks_created = 0;
231 cap->sparks_converted = 0;
232 cap->sparks_pruned = 0;
235 cap->f.stgEagerBlackholeInfo = (W_)&__stg_EAGER_BLACKHOLE_info;
236 cap->f.stgGCEnter1 = (StgFunPtr)__stg_gc_enter_1;
237 cap->f.stgGCFun = (StgFunPtr)__stg_gc_fun;
239 cap->mut_lists = stgMallocBytes(sizeof(bdescr *) *
240 RtsFlags.GcFlags.generations,
242 cap->saved_mut_lists = stgMallocBytes(sizeof(bdescr *) *
243 RtsFlags.GcFlags.generations,
246 for (g = 0; g < RtsFlags.GcFlags.generations; g++) {
247 cap->mut_lists[g] = NULL;
250 cap->free_tvar_watch_queues = END_STM_WATCH_QUEUE;
251 cap->free_invariant_check_queues = END_INVARIANT_CHECK_QUEUE;
252 cap->free_trec_chunks = END_STM_CHUNK_LIST;
253 cap->free_trec_headers = NO_TREC;
254 cap->transaction_tokens = 0;
255 cap->context_switch = 0;
256 cap->pinned_object_block = NULL;
259 /* ---------------------------------------------------------------------------
260 * Function: initCapabilities()
262 * Purpose: set up the Capability handling. For the THREADED_RTS build,
263 * we keep a table of them, the size of which is
264 * controlled by the user via the RTS flag -N.
266 * ------------------------------------------------------------------------- */
268 initCapabilities( void )
270 #if defined(THREADED_RTS)
274 // We can't support multiple CPUs if BaseReg is not a register
275 if (RtsFlags.ParFlags.nNodes > 1) {
276 errorBelch("warning: multiple CPUs not supported in this build, reverting to 1");
277 RtsFlags.ParFlags.nNodes = 1;
281 n_capabilities = RtsFlags.ParFlags.nNodes;
283 if (n_capabilities == 1) {
284 capabilities = &MainCapability;
285 // THREADED_RTS must work on builds that don't have a mutable
286 // BaseReg (eg. unregisterised), so in this case
287 // capabilities[0] must coincide with &MainCapability.
289 capabilities = stgMallocBytes(n_capabilities * sizeof(Capability),
293 for (i = 0; i < n_capabilities; i++) {
294 initCapability(&capabilities[i], i);
297 debugTrace(DEBUG_sched, "allocated %d capabilities", n_capabilities);
299 #else /* !THREADED_RTS */
302 capabilities = &MainCapability;
303 initCapability(&MainCapability, 0);
307 // There are no free capabilities to begin with. We will start
308 // a worker Task to each Capability, which will quickly put the
309 // Capability on the free list when it finds nothing to do.
310 last_free_capability = &capabilities[0];
313 /* ----------------------------------------------------------------------------
314 * setContextSwitches: cause all capabilities to context switch as
316 * ------------------------------------------------------------------------- */
318 void setContextSwitches(void)
321 for (i=0; i < n_capabilities; i++) {
322 contextSwitchCapability(&capabilities[i]);
326 /* ----------------------------------------------------------------------------
327 * Give a Capability to a Task. The task must currently be sleeping
328 * on its condition variable.
330 * Requires cap->lock (modifies cap->running_task).
332 * When migrating a Task, the migrater must take task->lock before
333 * modifying task->cap, to synchronise with the waking up Task.
334 * Additionally, the migrater should own the Capability (when
335 * migrating the run queue), or cap->lock (when migrating
336 * returning_workers).
338 * ------------------------------------------------------------------------- */
340 #if defined(THREADED_RTS)
342 giveCapabilityToTask (Capability *cap USED_IF_DEBUG, Task *task)
344 ASSERT_LOCK_HELD(&cap->lock);
345 ASSERT(task->cap == cap);
346 debugTrace(DEBUG_sched, "passing capability %d to %s %p",
347 cap->no, task->tso ? "bound task" : "worker",
349 ACQUIRE_LOCK(&task->lock);
350 task->wakeup = rtsTrue;
351 // the wakeup flag is needed because signalCondition() doesn't
352 // flag the condition if the thread is already runniing, but we want
354 signalCondition(&task->cond);
355 RELEASE_LOCK(&task->lock);
359 /* ----------------------------------------------------------------------------
360 * Function: releaseCapability(Capability*)
362 * Purpose: Letting go of a capability. Causes a
363 * 'returning worker' thread or a 'waiting worker'
364 * to wake up, in that order.
365 * ------------------------------------------------------------------------- */
367 #if defined(THREADED_RTS)
369 releaseCapability_ (Capability* cap,
370 rtsBool always_wakeup)
374 task = cap->running_task;
376 ASSERT_PARTIAL_CAPABILITY_INVARIANTS(cap,task);
378 cap->running_task = NULL;
380 // Check to see whether a worker thread can be given
381 // the go-ahead to return the result of an external call..
382 if (cap->returning_tasks_hd != NULL) {
383 giveCapabilityToTask(cap,cap->returning_tasks_hd);
384 // The Task pops itself from the queue (see waitForReturnCapability())
388 if (waiting_for_gc == PENDING_GC_SEQ) {
389 last_free_capability = cap; // needed?
390 debugTrace(DEBUG_sched, "GC pending, set capability %d free", cap->no);
395 // If the next thread on the run queue is a bound thread,
396 // give this Capability to the appropriate Task.
397 if (!emptyRunQueue(cap) && cap->run_queue_hd->bound) {
398 // Make sure we're not about to try to wake ourselves up
399 ASSERT(task != cap->run_queue_hd->bound);
400 task = cap->run_queue_hd->bound;
401 giveCapabilityToTask(cap,task);
405 if (!cap->spare_workers) {
406 // Create a worker thread if we don't have one. If the system
407 // is interrupted, we only create a worker task if there
408 // are threads that need to be completed. If the system is
409 // shutting down, we never create a new worker.
410 if (sched_state < SCHED_SHUTTING_DOWN || !emptyRunQueue(cap)) {
411 debugTrace(DEBUG_sched,
412 "starting new worker on capability %d", cap->no);
413 startWorkerTask(cap, workerStart);
418 // If we have an unbound thread on the run queue, or if there's
419 // anything else to do, give the Capability to a worker thread.
421 !emptyRunQueue(cap) || !emptyWakeupQueue(cap) ||
422 !emptySparkPoolCap(cap) || globalWorkToDo()) {
423 if (cap->spare_workers) {
424 giveCapabilityToTask(cap,cap->spare_workers);
425 // The worker Task pops itself from the queue;
430 last_free_capability = cap;
431 debugTrace(DEBUG_sched, "freeing capability %d", cap->no);
435 releaseCapability (Capability* cap USED_IF_THREADS)
437 ACQUIRE_LOCK(&cap->lock);
438 releaseCapability_(cap, rtsFalse);
439 RELEASE_LOCK(&cap->lock);
443 releaseAndWakeupCapability (Capability* cap USED_IF_THREADS)
445 ACQUIRE_LOCK(&cap->lock);
446 releaseCapability_(cap, rtsTrue);
447 RELEASE_LOCK(&cap->lock);
451 releaseCapabilityAndQueueWorker (Capability* cap USED_IF_THREADS)
455 ACQUIRE_LOCK(&cap->lock);
457 task = cap->running_task;
459 // If the current task is a worker, save it on the spare_workers
460 // list of this Capability. A worker can mark itself as stopped,
461 // in which case it is not replaced on the spare_worker queue.
462 // This happens when the system is shutting down (see
463 // Schedule.c:workerStart()).
464 // Also, be careful to check that this task hasn't just exited
465 // Haskell to do a foreign call (task->suspended_tso).
466 if (!isBoundTask(task) && !task->stopped && !task->suspended_tso) {
467 task->next = cap->spare_workers;
468 cap->spare_workers = task;
470 // Bound tasks just float around attached to their TSOs.
472 releaseCapability_(cap,rtsFalse);
474 RELEASE_LOCK(&cap->lock);
478 /* ----------------------------------------------------------------------------
479 * waitForReturnCapability( Task *task )
481 * Purpose: when an OS thread returns from an external call,
482 * it calls waitForReturnCapability() (via Schedule.resumeThread())
483 * to wait for permission to enter the RTS & communicate the
484 * result of the external call back to the Haskell thread that
487 * ------------------------------------------------------------------------- */
489 waitForReturnCapability (Capability **pCap, Task *task)
491 #if !defined(THREADED_RTS)
493 MainCapability.running_task = task;
494 task->cap = &MainCapability;
495 *pCap = &MainCapability;
498 Capability *cap = *pCap;
501 // Try last_free_capability first
502 cap = last_free_capability;
503 if (cap->running_task) {
505 // otherwise, search for a free capability
507 for (i = 0; i < n_capabilities; i++) {
508 if (!capabilities[i].running_task) {
509 cap = &capabilities[i];
514 // Can't find a free one, use last_free_capability.
515 cap = last_free_capability;
519 // record the Capability as the one this Task is now assocated with.
523 ASSERT(task->cap == cap);
526 ACQUIRE_LOCK(&cap->lock);
528 debugTrace(DEBUG_sched, "returning; I want capability %d", cap->no);
530 if (!cap->running_task) {
531 // It's free; just grab it
532 cap->running_task = task;
533 RELEASE_LOCK(&cap->lock);
535 newReturningTask(cap,task);
536 RELEASE_LOCK(&cap->lock);
539 ACQUIRE_LOCK(&task->lock);
540 // task->lock held, cap->lock not held
541 if (!task->wakeup) waitCondition(&task->cond, &task->lock);
543 task->wakeup = rtsFalse;
544 RELEASE_LOCK(&task->lock);
546 // now check whether we should wake up...
547 ACQUIRE_LOCK(&cap->lock);
548 if (cap->running_task == NULL) {
549 if (cap->returning_tasks_hd != task) {
550 giveCapabilityToTask(cap,cap->returning_tasks_hd);
551 RELEASE_LOCK(&cap->lock);
554 cap->running_task = task;
555 popReturningTask(cap);
556 RELEASE_LOCK(&cap->lock);
559 RELEASE_LOCK(&cap->lock);
564 ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task);
566 debugTrace(DEBUG_sched, "resuming capability %d", cap->no);
572 #if defined(THREADED_RTS)
573 /* ----------------------------------------------------------------------------
575 * ------------------------------------------------------------------------- */
578 yieldCapability (Capability** pCap, Task *task)
580 Capability *cap = *pCap;
582 if (waiting_for_gc == PENDING_GC_PAR) {
583 traceSchedEvent(cap, EVENT_GC_START, 0, 0);
585 traceSchedEvent(cap, EVENT_GC_END, 0, 0);
589 debugTrace(DEBUG_sched, "giving up capability %d", cap->no);
591 // We must now release the capability and wait to be woken up
593 task->wakeup = rtsFalse;
594 releaseCapabilityAndQueueWorker(cap);
597 ACQUIRE_LOCK(&task->lock);
598 // task->lock held, cap->lock not held
599 if (!task->wakeup) waitCondition(&task->cond, &task->lock);
601 task->wakeup = rtsFalse;
602 RELEASE_LOCK(&task->lock);
604 debugTrace(DEBUG_sched, "woken up on capability %d", cap->no);
606 ACQUIRE_LOCK(&cap->lock);
607 if (cap->running_task != NULL) {
608 debugTrace(DEBUG_sched,
609 "capability %d is owned by another task", cap->no);
610 RELEASE_LOCK(&cap->lock);
614 if (task->tso == NULL) {
615 ASSERT(cap->spare_workers != NULL);
616 // if we're not at the front of the queue, release it
617 // again. This is unlikely to happen.
618 if (cap->spare_workers != task) {
619 giveCapabilityToTask(cap,cap->spare_workers);
620 RELEASE_LOCK(&cap->lock);
623 cap->spare_workers = task->next;
626 cap->running_task = task;
627 RELEASE_LOCK(&cap->lock);
631 debugTrace(DEBUG_sched, "resuming capability %d", cap->no);
632 ASSERT(cap->running_task == task);
636 ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task);
641 /* ----------------------------------------------------------------------------
642 * Wake up a thread on a Capability.
644 * This is used when the current Task is running on a Capability and
645 * wishes to wake up a thread on a different Capability.
646 * ------------------------------------------------------------------------- */
649 wakeupThreadOnCapability (Capability *my_cap,
650 Capability *other_cap,
653 ACQUIRE_LOCK(&other_cap->lock);
655 // ASSUMES: cap->lock is held (asserted in wakeupThreadOnCapability)
657 ASSERT(tso->bound->cap == tso->cap);
658 tso->bound->cap = other_cap;
660 tso->cap = other_cap;
662 ASSERT(tso->bound ? tso->bound->cap == other_cap : 1);
664 if (other_cap->running_task == NULL) {
665 // nobody is running this Capability, we can add our thread
666 // directly onto the run queue and start up a Task to run it.
668 other_cap->running_task = myTask();
669 // precond for releaseCapability_() and appendToRunQueue()
671 appendToRunQueue(other_cap,tso);
673 releaseCapability_(other_cap,rtsFalse);
675 appendToWakeupQueue(my_cap,other_cap,tso);
676 other_cap->context_switch = 1;
677 // someone is running on this Capability, so it cannot be
678 // freed without first checking the wakeup queue (see
679 // releaseCapability_).
682 RELEASE_LOCK(&other_cap->lock);
685 /* ----------------------------------------------------------------------------
688 * If a Capability is currently idle, wake up a Task on it. Used to
689 * get every Capability into the GC.
690 * ------------------------------------------------------------------------- */
693 prodCapability (Capability *cap, Task *task)
695 ACQUIRE_LOCK(&cap->lock);
696 if (!cap->running_task) {
697 cap->running_task = task;
698 releaseCapability_(cap,rtsTrue);
700 RELEASE_LOCK(&cap->lock);
703 /* ----------------------------------------------------------------------------
706 * At shutdown time, we want to let everything exit as cleanly as
707 * possible. For each capability, we let its run queue drain, and
708 * allow the workers to stop.
710 * This function should be called when interrupted and
711 * shutting_down_scheduler = rtsTrue, thus any worker that wakes up
712 * will exit the scheduler and call taskStop(), and any bound thread
713 * that wakes up will return to its caller. Runnable threads are
716 * ------------------------------------------------------------------------- */
719 shutdownCapability (Capability *cap, Task *task, rtsBool safe)
725 // Loop indefinitely until all the workers have exited and there
726 // are no Haskell threads left. We used to bail out after 50
727 // iterations of this loop, but that occasionally left a worker
728 // running which caused problems later (the closeMutex() below
729 // isn't safe, for one thing).
731 for (i = 0; /* i < 50 */; i++) {
732 ASSERT(sched_state == SCHED_SHUTTING_DOWN);
734 debugTrace(DEBUG_sched,
735 "shutting down capability %d, attempt %d", cap->no, i);
736 ACQUIRE_LOCK(&cap->lock);
737 if (cap->running_task) {
738 RELEASE_LOCK(&cap->lock);
739 debugTrace(DEBUG_sched, "not owner, yielding");
743 cap->running_task = task;
745 if (cap->spare_workers) {
746 // Look for workers that have died without removing
747 // themselves from the list; this could happen if the OS
748 // summarily killed the thread, for example. This
749 // actually happens on Windows when the system is
750 // terminating the program, and the RTS is running in a
754 for (t = cap->spare_workers; t != NULL; t = t->next) {
755 if (!osThreadIsAlive(t->id)) {
756 debugTrace(DEBUG_sched,
757 "worker thread %p has died unexpectedly", (void *)t->id);
759 cap->spare_workers = t->next;
761 prev->next = t->next;
768 if (!emptyRunQueue(cap) || cap->spare_workers) {
769 debugTrace(DEBUG_sched,
770 "runnable threads or workers still alive, yielding");
771 releaseCapability_(cap,rtsFalse); // this will wake up a worker
772 RELEASE_LOCK(&cap->lock);
777 // If "safe", then busy-wait for any threads currently doing
778 // foreign calls. If we're about to unload this DLL, for
779 // example, we need to be sure that there are no OS threads
780 // that will try to return to code that has been unloaded.
781 // We can be a bit more relaxed when this is a standalone
782 // program that is about to terminate, and let safe=false.
783 if (cap->suspended_ccalling_tasks && safe) {
784 debugTrace(DEBUG_sched,
785 "thread(s) are involved in foreign calls, yielding");
786 cap->running_task = NULL;
787 RELEASE_LOCK(&cap->lock);
792 traceSchedEvent(cap, EVENT_SHUTDOWN, 0, 0);
793 RELEASE_LOCK(&cap->lock);
796 // we now have the Capability, its run queue and spare workers
797 // list are both empty.
799 // ToDo: we can't drop this mutex, because there might still be
800 // threads performing foreign calls that will eventually try to
801 // return via resumeThread() and attempt to grab cap->lock.
802 // closeMutex(&cap->lock);
805 /* ----------------------------------------------------------------------------
808 * Attempt to gain control of a Capability if it is free.
810 * ------------------------------------------------------------------------- */
813 tryGrabCapability (Capability *cap, Task *task)
815 if (cap->running_task != NULL) return rtsFalse;
816 ACQUIRE_LOCK(&cap->lock);
817 if (cap->running_task != NULL) {
818 RELEASE_LOCK(&cap->lock);
822 cap->running_task = task;
823 RELEASE_LOCK(&cap->lock);
828 #endif /* THREADED_RTS */
831 freeCapability (Capability *cap)
833 stgFree(cap->mut_lists);
834 stgFree(cap->saved_mut_lists);
835 #if defined(THREADED_RTS)
836 freeSparkPool(cap->sparks);
841 freeCapabilities (void)
843 #if defined(THREADED_RTS)
845 for (i=0; i < n_capabilities; i++) {
846 freeCapability(&capabilities[i]);
849 freeCapability(&MainCapability);
853 /* ---------------------------------------------------------------------------
854 Mark everything directly reachable from the Capabilities. When
855 using multiple GC threads, each GC thread marks all Capabilities
856 for which (c `mod` n == 0), for Capability c and thread n.
857 ------------------------------------------------------------------------ */
860 markSomeCapabilities (evac_fn evac, void *user, nat i0, nat delta,
861 rtsBool prune_sparks USED_IF_THREADS)
867 // Each GC thread is responsible for following roots from the
868 // Capability of the same number. There will usually be the same
869 // or fewer Capabilities as GC threads, but just in case there
870 // are more, we mark every Capability whose number is the GC
871 // thread's index plus a multiple of the number of GC threads.
872 for (i = i0; i < n_capabilities; i += delta) {
873 cap = &capabilities[i];
874 evac(user, (StgClosure **)(void *)&cap->run_queue_hd);
875 evac(user, (StgClosure **)(void *)&cap->run_queue_tl);
876 #if defined(THREADED_RTS)
877 evac(user, (StgClosure **)(void *)&cap->wakeup_queue_hd);
878 evac(user, (StgClosure **)(void *)&cap->wakeup_queue_tl);
880 for (task = cap->suspended_ccalling_tasks; task != NULL;
882 evac(user, (StgClosure **)(void *)&task->suspended_tso);
885 #if defined(THREADED_RTS)
887 pruneSparkQueue (evac, user, cap);
889 traverseSparkQueue (evac, user, cap);
894 #if !defined(THREADED_RTS)
895 evac(user, (StgClosure **)(void *)&blocked_queue_hd);
896 evac(user, (StgClosure **)(void *)&blocked_queue_tl);
897 evac(user, (StgClosure **)(void *)&sleeping_queue);
902 markCapabilities (evac_fn evac, void *user)
904 markSomeCapabilities(evac, user, 0, 1, rtsFalse);