// has tidied up its stack and placed itself on whatever queue
// it needs to be on.
-#if !defined(THREADED_RTS)
- ASSERT(t->why_blocked != NotBlocked);
- // This might not be true under THREADED_RTS: we don't have
- // exclusive access to this TSO, so someone might have
- // woken it up by now. This actually happens: try
- // conc023 +RTS -N2.
-#endif
+ // ASSERT(t->why_blocked != NotBlocked);
+ // Not true: for example,
+ // - in THREADED_RTS, the thread may already have been woken
+ // up by another Capability. This actually happens: try
+ // conc023 +RTS -N2.
+ // - the thread may have woken itself up already, because
+ // threadPaused() might have raised a blocked throwTo
+ // exception, see maybePerformBlockedException().
#ifdef DEBUG
if (traceClass(DEBUG_sched)) {
(unsigned long)t->id, whatNext_strs[t->what_next]);
/* Inform the Hpc that a thread has finished */
- hs_hpc_event("Thread Finished",t);
+ hs_hpc_thread_finished_event(t);
#if defined(GRAN)
endThread(t, CurrentProc); // clean-up the thread
boundTaskExiting(task);
stopTaskManager();
}
+#else
+ freeCapability(&MainCapability);
#endif
}
freeScheduler( void )
{
freeTaskManager();
+ if (n_capabilities != 1) {
+ stgFree(capabilities);
+ }
#if defined(THREADED_RTS)
closeMutex(&sched_mutex);
#endif