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"
24 #include "OSThreads.h"
25 #include "Capability.h"
30 // one global capability, this is the Capability for non-threaded
31 // builds, and for +RTS -N1
32 Capability MainCapability;
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;
43 /* GC indicator, in scope for the scheduler, init'ed to false */
44 volatile StgWord waiting_for_gc = 0;
46 #if defined(THREADED_RTS)
50 return blackholes_need_checking
51 || sched_state >= SCHED_INTERRUPTING
56 #if defined(THREADED_RTS)
57 rtsBool stealWork( Capability *cap) {
58 /* use the normal Sparks.h interface (internally modified to enable
60 and immediately turn the spark into a thread when successful
65 rtsBool success = rtsFalse;
68 debugTrace(DEBUG_sched,
69 "cap %d: Trying to steal work from other capabilities",
72 if (n_capabilities == 1) { return rtsFalse; } // makes no sense...
74 /* visit cap.s 0..n-1 in sequence until a theft succeeds. We could
75 start at a random place instead of 0 as well. */
76 for ( i=0 ; i < n_capabilities ; i++ ) {
77 robbed = &capabilities[i];
78 if (cap == robbed) // ourselves...
81 if (emptySparkPoolCap(robbed)) // nothing to steal here
84 spark = findSpark(robbed);
86 if (spark == NULL && !emptySparkPoolCap(robbed)) {
87 spark = findSpark(robbed); // lost race in concurrent access, try again
90 debugTrace(DEBUG_sched,
91 "cap %d: Stole a spark from capability %d",
94 createSparkThread(cap,spark);
96 break; // got one, leave the loop
98 // otherwise: no success, try next one
100 debugTrace(DEBUG_sched,
101 "Leaving work stealing routine (%s)",
102 success?"one spark stolen":"thefts did not succeed");
106 STATIC_INLINE rtsBool
107 anyWorkForMe( Capability *cap, Task *task )
109 if (task->tso != NULL) {
110 // A bound task only runs if its thread is on the run queue of
111 // the capability on which it was woken up. Otherwise, we
112 // can't be sure that we have the right capability: the thread
113 // might be woken up on some other capability, and task->cap
114 // could change under our feet.
115 return !emptyRunQueue(cap) && cap->run_queue_hd->bound == task;
117 // A vanilla worker task runs if either there is a lightweight
118 // thread at the head of the run queue, or the run queue is
119 // empty and (there are sparks to execute, or there is some
120 // other global condition to check, such as threads blocked on
122 if (emptyRunQueue(cap)) {
123 return !emptySparkPoolCap(cap)
124 || !emptyWakeupQueue(cap)
126 || stealWork(cap); /* if all false: try to steal work */
128 return cap->run_queue_hd->bound == NULL;
134 /* -----------------------------------------------------------------------------
135 * Manage the returning_tasks lists.
137 * These functions require cap->lock
138 * -------------------------------------------------------------------------- */
140 #if defined(THREADED_RTS)
142 newReturningTask (Capability *cap, Task *task)
144 ASSERT_LOCK_HELD(&cap->lock);
145 ASSERT(task->return_link == NULL);
146 if (cap->returning_tasks_hd) {
147 ASSERT(cap->returning_tasks_tl->return_link == NULL);
148 cap->returning_tasks_tl->return_link = task;
150 cap->returning_tasks_hd = task;
152 cap->returning_tasks_tl = task;
156 popReturningTask (Capability *cap)
158 ASSERT_LOCK_HELD(&cap->lock);
160 task = cap->returning_tasks_hd;
162 cap->returning_tasks_hd = task->return_link;
163 if (!cap->returning_tasks_hd) {
164 cap->returning_tasks_tl = NULL;
166 task->return_link = NULL;
171 /* ----------------------------------------------------------------------------
174 * The Capability is initially marked not free.
175 * ------------------------------------------------------------------------- */
178 initCapability( Capability *cap, nat i )
183 cap->in_haskell = rtsFalse;
185 cap->run_queue_hd = END_TSO_QUEUE;
186 cap->run_queue_tl = END_TSO_QUEUE;
188 #if defined(THREADED_RTS)
189 initMutex(&cap->lock);
190 cap->running_task = NULL; // indicates cap is free
191 cap->spare_workers = NULL;
192 cap->suspended_ccalling_tasks = NULL;
193 cap->returning_tasks_hd = NULL;
194 cap->returning_tasks_tl = NULL;
195 cap->wakeup_queue_hd = END_TSO_QUEUE;
196 cap->wakeup_queue_tl = END_TSO_QUEUE;
199 cap->f.stgGCEnter1 = (F_)__stg_gc_enter_1;
200 cap->f.stgGCFun = (F_)__stg_gc_fun;
202 cap->mut_lists = stgMallocBytes(sizeof(bdescr *) *
203 RtsFlags.GcFlags.generations,
206 for (g = 0; g < RtsFlags.GcFlags.generations; g++) {
207 cap->mut_lists[g] = NULL;
210 cap->free_tvar_watch_queues = END_STM_WATCH_QUEUE;
211 cap->free_invariant_check_queues = END_INVARIANT_CHECK_QUEUE;
212 cap->free_trec_chunks = END_STM_CHUNK_LIST;
213 cap->free_trec_headers = NO_TREC;
214 cap->transaction_tokens = 0;
215 cap->context_switch = 0;
218 /* ---------------------------------------------------------------------------
219 * Function: initCapabilities()
221 * Purpose: set up the Capability handling. For the THREADED_RTS build,
222 * we keep a table of them, the size of which is
223 * controlled by the user via the RTS flag -N.
225 * ------------------------------------------------------------------------- */
227 initCapabilities( void )
229 #if defined(THREADED_RTS)
233 // We can't support multiple CPUs if BaseReg is not a register
234 if (RtsFlags.ParFlags.nNodes > 1) {
235 errorBelch("warning: multiple CPUs not supported in this build, reverting to 1");
236 RtsFlags.ParFlags.nNodes = 1;
240 n_capabilities = RtsFlags.ParFlags.nNodes;
242 if (n_capabilities == 1) {
243 capabilities = &MainCapability;
244 // THREADED_RTS must work on builds that don't have a mutable
245 // BaseReg (eg. unregisterised), so in this case
246 // capabilities[0] must coincide with &MainCapability.
248 capabilities = stgMallocBytes(n_capabilities * sizeof(Capability),
252 for (i = 0; i < n_capabilities; i++) {
253 initCapability(&capabilities[i], i);
256 debugTrace(DEBUG_sched, "allocated %d capabilities", n_capabilities);
258 #else /* !THREADED_RTS */
261 capabilities = &MainCapability;
262 initCapability(&MainCapability, 0);
266 // There are no free capabilities to begin with. We will start
267 // a worker Task to each Capability, which will quickly put the
268 // Capability on the free list when it finds nothing to do.
269 last_free_capability = &capabilities[0];
272 /* ----------------------------------------------------------------------------
273 * setContextSwitches: cause all capabilities to context switch as
275 * ------------------------------------------------------------------------- */
277 void setContextSwitches(void)
280 for (i=0; i < n_capabilities; i++) {
281 capabilities[i].context_switch = 1;
285 /* ----------------------------------------------------------------------------
286 * Give a Capability to a Task. The task must currently be sleeping
287 * on its condition variable.
289 * Requires cap->lock (modifies cap->running_task).
291 * When migrating a Task, the migrater must take task->lock before
292 * modifying task->cap, to synchronise with the waking up Task.
293 * Additionally, the migrater should own the Capability (when
294 * migrating the run queue), or cap->lock (when migrating
295 * returning_workers).
297 * ------------------------------------------------------------------------- */
299 #if defined(THREADED_RTS)
301 giveCapabilityToTask (Capability *cap USED_IF_DEBUG, Task *task)
303 ASSERT_LOCK_HELD(&cap->lock);
304 ASSERT(task->cap == cap);
305 trace(TRACE_sched | DEBUG_sched,
306 "passing capability %d to %s %p",
307 cap->no, task->tso ? "bound task" : "worker",
309 ACQUIRE_LOCK(&task->lock);
310 task->wakeup = rtsTrue;
311 // the wakeup flag is needed because signalCondition() doesn't
312 // flag the condition if the thread is already runniing, but we want
314 signalCondition(&task->cond);
315 RELEASE_LOCK(&task->lock);
319 /* ----------------------------------------------------------------------------
320 * Function: releaseCapability(Capability*)
322 * Purpose: Letting go of a capability. Causes a
323 * 'returning worker' thread or a 'waiting worker'
324 * to wake up, in that order.
325 * ------------------------------------------------------------------------- */
327 #if defined(THREADED_RTS)
329 releaseCapability_ (Capability* cap)
333 task = cap->running_task;
335 ASSERT_PARTIAL_CAPABILITY_INVARIANTS(cap,task);
337 cap->running_task = NULL;
339 // Check to see whether a worker thread can be given
340 // the go-ahead to return the result of an external call..
341 if (cap->returning_tasks_hd != NULL) {
342 giveCapabilityToTask(cap,cap->returning_tasks_hd);
343 // The Task pops itself from the queue (see waitForReturnCapability())
347 /* if waiting_for_gc was the reason to release the cap: thread
348 comes from yieldCap->releaseAndQueueWorker. Unconditionally set
349 cap. free and return (see default after the if-protected other
350 special cases). Thread will wait on cond.var and re-acquire the
351 same cap after GC (GC-triggering cap. calls releaseCap and
352 enters the spare_workers case)
354 if (waiting_for_gc) {
355 last_free_capability = cap; // needed?
356 trace(TRACE_sched | DEBUG_sched,
357 "GC pending, set capability %d free", cap->no);
362 // If the next thread on the run queue is a bound thread,
363 // give this Capability to the appropriate Task.
364 if (!emptyRunQueue(cap) && cap->run_queue_hd->bound) {
365 // Make sure we're not about to try to wake ourselves up
366 ASSERT(task != cap->run_queue_hd->bound);
367 task = cap->run_queue_hd->bound;
368 giveCapabilityToTask(cap,task);
372 if (!cap->spare_workers) {
373 // Create a worker thread if we don't have one. If the system
374 // is interrupted, we only create a worker task if there
375 // are threads that need to be completed. If the system is
376 // shutting down, we never create a new worker.
377 if (sched_state < SCHED_SHUTTING_DOWN || !emptyRunQueue(cap)) {
378 debugTrace(DEBUG_sched,
379 "starting new worker on capability %d", cap->no);
380 startWorkerTask(cap, workerStart);
385 // If we have an unbound thread on the run queue, or if there's
386 // anything else to do, give the Capability to a worker thread.
387 if (!emptyRunQueue(cap) || !emptyWakeupQueue(cap)
388 || !emptySparkPoolCap(cap) || globalWorkToDo()) {
389 if (cap->spare_workers) {
390 giveCapabilityToTask(cap,cap->spare_workers);
391 // The worker Task pops itself from the queue;
396 last_free_capability = cap;
397 trace(TRACE_sched | DEBUG_sched, "freeing capability %d", cap->no);
401 releaseCapability (Capability* cap USED_IF_THREADS)
403 ACQUIRE_LOCK(&cap->lock);
404 releaseCapability_(cap);
405 RELEASE_LOCK(&cap->lock);
409 releaseCapabilityAndQueueWorker (Capability* cap USED_IF_THREADS)
413 ACQUIRE_LOCK(&cap->lock);
415 task = cap->running_task;
417 // If the current task is a worker, save it on the spare_workers
418 // list of this Capability. A worker can mark itself as stopped,
419 // in which case it is not replaced on the spare_worker queue.
420 // This happens when the system is shutting down (see
421 // Schedule.c:workerStart()).
422 // Also, be careful to check that this task hasn't just exited
423 // Haskell to do a foreign call (task->suspended_tso).
424 if (!isBoundTask(task) && !task->stopped && !task->suspended_tso) {
425 task->next = cap->spare_workers;
426 cap->spare_workers = task;
428 // Bound tasks just float around attached to their TSOs.
430 releaseCapability_(cap);
432 RELEASE_LOCK(&cap->lock);
436 /* ----------------------------------------------------------------------------
437 * waitForReturnCapability( Task *task )
439 * Purpose: when an OS thread returns from an external call,
440 * it calls waitForReturnCapability() (via Schedule.resumeThread())
441 * to wait for permission to enter the RTS & communicate the
442 * result of the external call back to the Haskell thread that
445 * ------------------------------------------------------------------------- */
447 waitForReturnCapability (Capability **pCap, Task *task)
449 #if !defined(THREADED_RTS)
451 MainCapability.running_task = task;
452 task->cap = &MainCapability;
453 *pCap = &MainCapability;
456 Capability *cap = *pCap;
459 // Try last_free_capability first
460 cap = last_free_capability;
461 if (!cap->running_task) {
463 // otherwise, search for a free capability
464 for (i = 0; i < n_capabilities; i++) {
465 cap = &capabilities[i];
466 if (!cap->running_task) {
470 // Can't find a free one, use last_free_capability.
471 cap = last_free_capability;
474 // record the Capability as the one this Task is now assocated with.
478 ASSERT(task->cap == cap);
481 ACQUIRE_LOCK(&cap->lock);
483 debugTrace(DEBUG_sched, "returning; I want capability %d", cap->no);
485 if (!cap->running_task) {
486 // It's free; just grab it
487 cap->running_task = task;
488 RELEASE_LOCK(&cap->lock);
490 newReturningTask(cap,task);
491 RELEASE_LOCK(&cap->lock);
494 ACQUIRE_LOCK(&task->lock);
495 // task->lock held, cap->lock not held
496 if (!task->wakeup) waitCondition(&task->cond, &task->lock);
498 task->wakeup = rtsFalse;
499 RELEASE_LOCK(&task->lock);
501 // now check whether we should wake up...
502 ACQUIRE_LOCK(&cap->lock);
503 if (cap->running_task == NULL) {
504 if (cap->returning_tasks_hd != task) {
505 giveCapabilityToTask(cap,cap->returning_tasks_hd);
506 RELEASE_LOCK(&cap->lock);
509 cap->running_task = task;
510 popReturningTask(cap);
511 RELEASE_LOCK(&cap->lock);
514 RELEASE_LOCK(&cap->lock);
519 ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task);
521 trace(TRACE_sched | DEBUG_sched, "resuming capability %d", cap->no);
527 #if defined(THREADED_RTS)
528 /* ----------------------------------------------------------------------------
530 * ------------------------------------------------------------------------- */
533 yieldCapability (Capability** pCap, Task *task)
535 Capability *cap = *pCap;
537 // The fast path has no locking, if we don't enter this while loop
539 while ( waiting_for_gc
540 /* i.e. another capability triggered HeapOverflow, is busy
541 getting capabilities (stopping their owning tasks) */
542 || cap->returning_tasks_hd != NULL
543 /* cap reserved for another task */
544 || !anyWorkForMe(cap,task)
545 /* cap/task have no work */
547 debugTrace(DEBUG_sched, "giving up capability %d", cap->no);
549 // We must now release the capability and wait to be woken up
551 task->wakeup = rtsFalse;
552 releaseCapabilityAndQueueWorker(cap);
555 ACQUIRE_LOCK(&task->lock);
556 // task->lock held, cap->lock not held
557 if (!task->wakeup) waitCondition(&task->cond, &task->lock);
559 task->wakeup = rtsFalse;
560 RELEASE_LOCK(&task->lock);
562 debugTrace(DEBUG_sched, "woken up on capability %d", cap->no);
564 ACQUIRE_LOCK(&cap->lock);
565 if (cap->running_task != NULL) {
566 debugTrace(DEBUG_sched,
567 "capability %d is owned by another task", cap->no);
568 RELEASE_LOCK(&cap->lock);
572 if (task->tso == NULL) {
573 ASSERT(cap->spare_workers != NULL);
574 // if we're not at the front of the queue, release it
575 // again. This is unlikely to happen.
576 if (cap->spare_workers != task) {
577 giveCapabilityToTask(cap,cap->spare_workers);
578 RELEASE_LOCK(&cap->lock);
581 cap->spare_workers = task->next;
584 cap->running_task = task;
585 RELEASE_LOCK(&cap->lock);
589 trace(TRACE_sched | DEBUG_sched, "resuming capability %d", cap->no);
590 ASSERT(cap->running_task == task);
595 ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task);
600 /* ----------------------------------------------------------------------------
601 * Wake up a thread on a Capability.
603 * This is used when the current Task is running on a Capability and
604 * wishes to wake up a thread on a different Capability.
605 * ------------------------------------------------------------------------- */
608 wakeupThreadOnCapability (Capability *my_cap,
609 Capability *other_cap,
612 ACQUIRE_LOCK(&other_cap->lock);
614 // ASSUMES: cap->lock is held (asserted in wakeupThreadOnCapability)
616 ASSERT(tso->bound->cap == tso->cap);
617 tso->bound->cap = other_cap;
619 tso->cap = other_cap;
621 ASSERT(tso->bound ? tso->bound->cap == other_cap : 1);
623 if (other_cap->running_task == NULL) {
624 // nobody is running this Capability, we can add our thread
625 // directly onto the run queue and start up a Task to run it.
627 other_cap->running_task = myTask();
628 // precond for releaseCapability_() and appendToRunQueue()
630 appendToRunQueue(other_cap,tso);
632 trace(TRACE_sched, "resuming capability %d", other_cap->no);
633 releaseCapability_(other_cap);
635 appendToWakeupQueue(my_cap,other_cap,tso);
636 other_cap->context_switch = 1;
637 // someone is running on this Capability, so it cannot be
638 // freed without first checking the wakeup queue (see
639 // releaseCapability_).
642 RELEASE_LOCK(&other_cap->lock);
645 /* ----------------------------------------------------------------------------
648 * Used to indicate that the interrupted flag is now set, or some
649 * other global condition that might require waking up a Task on each
651 * ------------------------------------------------------------------------- */
654 prodCapabilities(rtsBool all)
660 for (i=0; i < n_capabilities; i++) {
661 cap = &capabilities[i];
662 ACQUIRE_LOCK(&cap->lock);
663 if (!cap->running_task) {
664 if (cap->spare_workers) {
665 trace(TRACE_sched, "resuming capability %d", cap->no);
666 task = cap->spare_workers;
667 ASSERT(!task->stopped);
668 giveCapabilityToTask(cap,task);
670 RELEASE_LOCK(&cap->lock);
675 RELEASE_LOCK(&cap->lock);
681 prodAllCapabilities (void)
683 prodCapabilities(rtsTrue);
686 /* ----------------------------------------------------------------------------
689 * Like prodAllCapabilities, but we only require a single Task to wake
690 * up in order to service some global event, such as checking for
691 * deadlock after some idle time has passed.
692 * ------------------------------------------------------------------------- */
695 prodOneCapability (void)
697 prodCapabilities(rtsFalse);
700 /* ----------------------------------------------------------------------------
703 * At shutdown time, we want to let everything exit as cleanly as
704 * possible. For each capability, we let its run queue drain, and
705 * allow the workers to stop.
707 * This function should be called when interrupted and
708 * shutting_down_scheduler = rtsTrue, thus any worker that wakes up
709 * will exit the scheduler and call taskStop(), and any bound thread
710 * that wakes up will return to its caller. Runnable threads are
713 * ------------------------------------------------------------------------- */
716 shutdownCapability (Capability *cap, Task *task, rtsBool safe)
720 ASSERT(sched_state == SCHED_SHUTTING_DOWN);
724 // Loop indefinitely until all the workers have exited and there
725 // are no Haskell threads left. We used to bail out after 50
726 // iterations of this loop, but that occasionally left a worker
727 // running which caused problems later (the closeMutex() below
728 // isn't safe, for one thing).
730 for (i = 0; /* i < 50 */; i++) {
731 debugTrace(DEBUG_sched,
732 "shutting down capability %d, attempt %d", cap->no, i);
733 ACQUIRE_LOCK(&cap->lock);
734 if (cap->running_task) {
735 RELEASE_LOCK(&cap->lock);
736 debugTrace(DEBUG_sched, "not owner, yielding");
740 cap->running_task = task;
742 if (cap->spare_workers) {
743 // Look for workers that have died without removing
744 // themselves from the list; this could happen if the OS
745 // summarily killed the thread, for example. This
746 // actually happens on Windows when the system is
747 // terminating the program, and the RTS is running in a
751 for (t = cap->spare_workers; t != NULL; t = t->next) {
752 if (!osThreadIsAlive(t->id)) {
753 debugTrace(DEBUG_sched,
754 "worker thread %p has died unexpectedly", (void *)t->id);
756 cap->spare_workers = t->next;
758 prev->next = t->next;
765 if (!emptyRunQueue(cap) || cap->spare_workers) {
766 debugTrace(DEBUG_sched,
767 "runnable threads or workers still alive, yielding");
768 releaseCapability_(cap); // this will wake up a worker
769 RELEASE_LOCK(&cap->lock);
774 // If "safe", then busy-wait for any threads currently doing
775 // foreign calls. If we're about to unload this DLL, for
776 // example, we need to be sure that there are no OS threads
777 // that will try to return to code that has been unloaded.
778 // We can be a bit more relaxed when this is a standalone
779 // program that is about to terminate, and let safe=false.
780 if (cap->suspended_ccalling_tasks && safe) {
781 debugTrace(DEBUG_sched,
782 "thread(s) are involved in foreign calls, yielding");
783 cap->running_task = NULL;
784 RELEASE_LOCK(&cap->lock);
789 debugTrace(DEBUG_sched, "capability %d is stopped.", cap->no);
791 RELEASE_LOCK(&cap->lock);
794 // we now have the Capability, its run queue and spare workers
795 // list are both empty.
797 // ToDo: we can't drop this mutex, because there might still be
798 // threads performing foreign calls that will eventually try to
799 // return via resumeThread() and attempt to grab cap->lock.
800 // closeMutex(&cap->lock);
803 /* ----------------------------------------------------------------------------
806 * Attempt to gain control of a Capability if it is free.
808 * ------------------------------------------------------------------------- */
811 tryGrabCapability (Capability *cap, Task *task)
813 if (cap->running_task != NULL) return rtsFalse;
814 ACQUIRE_LOCK(&cap->lock);
815 if (cap->running_task != NULL) {
816 RELEASE_LOCK(&cap->lock);
820 cap->running_task = task;
821 RELEASE_LOCK(&cap->lock);
826 #endif /* THREADED_RTS */
829 freeCapability (Capability *cap) {
830 stgFree(cap->mut_lists);
831 #if defined(THREADED_RTS) || defined(PARALLEL_HASKELL)
832 freeSparkPool(cap->sparks);
836 /* ---------------------------------------------------------------------------
837 Mark everything directly reachable from the Capabilities. When
838 using multiple GC threads, each GC thread marks all Capabilities
839 for which (c `mod` n == 0), for Capability c and thread n.
840 ------------------------------------------------------------------------ */
843 markSomeCapabilities (evac_fn evac, void *user, nat i0, nat delta)
849 // Each GC thread is responsible for following roots from the
850 // Capability of the same number. There will usually be the same
851 // or fewer Capabilities as GC threads, but just in case there
852 // are more, we mark every Capability whose number is the GC
853 // thread's index plus a multiple of the number of GC threads.
854 for (i = i0; i < n_capabilities; i += delta) {
855 cap = &capabilities[i];
856 evac(user, (StgClosure **)(void *)&cap->run_queue_hd);
857 evac(user, (StgClosure **)(void *)&cap->run_queue_tl);
858 #if defined(THREADED_RTS)
859 evac(user, (StgClosure **)(void *)&cap->wakeup_queue_hd);
860 evac(user, (StgClosure **)(void *)&cap->wakeup_queue_tl);
862 for (task = cap->suspended_ccalling_tasks; task != NULL;
864 debugTrace(DEBUG_sched,
865 "evac'ing suspended TSO %lu", (unsigned long)task->suspended_tso->id);
866 evac(user, (StgClosure **)(void *)&task->suspended_tso);
869 #if defined(THREADED_RTS)
870 traverseSparkQueue (evac, user, cap);
874 #if !defined(THREADED_RTS)
875 evac(user, (StgClosure **)(void *)&blocked_queue_hd);
876 evac(user, (StgClosure **)(void *)&blocked_queue_tl);
877 evac(user, (StgClosure **)(void *)&sleeping_queue);
881 // This function is used by the compacting GC to thread all the
882 // pointers from spark queues.
884 traverseSparkQueues (evac_fn evac USED_IF_THREADS, void *user USED_IF_THREADS)
886 #if defined(THREADED_RTS)
888 for (i = 0; i < n_capabilities; i++) {
889 traverseSparkQueue (evac, user, &capabilities[i]);
891 #endif // THREADED_RTS
896 markCapabilities (evac_fn evac, void *user)
898 markSomeCapabilities(evac, user, 0, 1);