X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2FSchedule.c;h=f67fcd98571f93292592dba50cea35af430db9a9;hp=77dcf411c747a2d50126db392b7cad561f15ddec;hb=f4b8374442162769ea87c24bf90a0f86a2fdd9b7;hpb=cf6b495d8f6d8f08fd6603c5ba2ec7a6acf7ac01 diff --git a/rts/Schedule.c b/rts/Schedule.c index 77dcf41..f67fcd9 100644 --- a/rts/Schedule.c +++ b/rts/Schedule.c @@ -1768,13 +1768,14 @@ scheduleHandleThreadBlocked( StgTSO *t // 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)) { @@ -1808,6 +1809,9 @@ scheduleHandleThreadFinished (Capability *cap STG_UNUSED, Task *task, StgTSO *t) debugTrace(DEBUG_sched, "--++ thread %lu (%s) finished", (unsigned long)t->id, whatNext_strs[t->what_next]); + /* Inform the Hpc that a thread has finished */ + hs_hpc_event("Thread Finished",t); + #if defined(GRAN) endThread(t, CurrentProc); // clean-up the thread #elif defined(PARALLEL_HASKELL) @@ -2578,7 +2582,8 @@ exitScheduler( void ) boundTaskExiting(task); stopTaskManager(); } - closeMutex(&sched_mutex); +#else + freeCapability(&MainCapability); #endif } @@ -2586,6 +2591,12 @@ void freeScheduler( void ) { freeTaskManager(); + if (n_capabilities != 1) { + stgFree(capabilities); + } +#if defined(THREADED_RTS) + closeMutex(&sched_mutex); +#endif } /* ---------------------------------------------------------------------------