Commit 6ffb1cec authored by Simon Marlow's avatar Simon Marlow
Browse files

Don't free sched_mutex until freeTaskManager has finished with it

Also move closeMutex() etc. into freeTaskManager, this is a free-ish thing
parent 55476c33
...@@ -2578,7 +2578,6 @@ exitScheduler( void ) ...@@ -2578,7 +2578,6 @@ exitScheduler( void )
boundTaskExiting(task); boundTaskExiting(task);
stopTaskManager(); stopTaskManager();
} }
closeMutex(&sched_mutex);
#endif #endif
} }
...@@ -2586,6 +2585,9 @@ void ...@@ -2586,6 +2585,9 @@ void
freeScheduler( void ) freeScheduler( void )
{ {
freeTaskManager(); freeTaskManager();
#if defined(THREADED_RTS)
closeMutex(&sched_mutex);
#endif
} }
/* --------------------------------------------------------------------------- /* ---------------------------------------------------------------------------
......
...@@ -68,20 +68,10 @@ initTaskManager (void) ...@@ -68,20 +68,10 @@ initTaskManager (void)
void void
stopTaskManager (void) stopTaskManager (void)
{ {
Task *task;
debugTrace(DEBUG_sched, debugTrace(DEBUG_sched,
"stopping task manager, %d tasks still running", "stopping task manager, %d tasks still running",
tasksRunning); tasksRunning);
/* nothing to do */
ACQUIRE_LOCK(&sched_mutex);
for (task = task_free_list; task != NULL; task = task->next) {
#if defined(THREADED_RTS)
closeCondition(&task->cond);
closeMutex(&task->lock);
#endif
}
RELEASE_LOCK(&sched_mutex);
} }
...@@ -94,6 +84,10 @@ freeTaskManager (void) ...@@ -94,6 +84,10 @@ freeTaskManager (void)
ACQUIRE_LOCK(&sched_mutex); ACQUIRE_LOCK(&sched_mutex);
for (task = task_free_list; task != NULL; task = next) { for (task = task_free_list; task != NULL; task = next) {
#if defined(THREADED_RTS)
closeCondition(&task->cond);
closeMutex(&task->lock);
#endif
next = task->next; next = task->next;
stgFree(task); stgFree(task);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment