X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FTask.c;h=0e51dbf1248655c9aa8e5718e81743b062a22f0b;hb=7cca410a40cccf0fbeda2155f307baa5619b8130;hp=a03ed8765112e990b3203371459a3c862a2c9088;hpb=88b35c172f9434fd98b700f706074d142914a8bb;p=ghc-hetmet.git diff --git a/rts/Task.c b/rts/Task.c index a03ed87..0e51dbf 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -15,6 +15,7 @@ #include "Capability.h" #include "Stats.h" #include "RtsFlags.h" +#include "Storage.h" #include "Schedule.h" #include "Hash.h" #include "Trace.h" @@ -67,21 +68,35 @@ initTaskManager (void) void stopTaskManager (void) { - Task *task, *next; + Task *task; debugTrace(DEBUG_sched, "stopping task manager, %d tasks still running", tasksRunning); ACQUIRE_LOCK(&sched_mutex); - for (task = task_free_list; task != NULL; task = next) { - next = task->next; - stgFree(task); + 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); +} + + +void +freeTaskManager (void) +{ + Task *task, *next; + + debugTrace(DEBUG_sched, "freeing task manager"); + + ACQUIRE_LOCK(&sched_mutex); + for (task = task_free_list; task != NULL; task = next) { + next = task->next; + stgFree(task); + } task_free_list = NULL; RELEASE_LOCK(&sched_mutex); } @@ -283,7 +298,8 @@ startWorkerTask (Capability *cap, r = createOSThread(&tid, (OSThreadProc *)taskStart, task); if (r != 0) { - barf("startTask: Can't create new task"); + sysErrorBelch("failed to create OS thread"); + stg_exit(EXIT_FAILURE); } debugTrace(DEBUG_sched, "new worker task (taskCount: %d)", taskCount);