X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FTask.c;h=e77a030f39ba565eb89a0c8132ede83e6e923612;hb=cd47700887365ca2a6af17d03e731efce65cf2ac;hp=f26785a1bedd93ab7947bd60dcde46097990de94;hpb=83d563cb9ede0ba792836e529b1e2929db926355;p=ghc-hetmet.git diff --git a/rts/Task.c b/rts/Task.c index f26785a..e77a030 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -270,8 +270,6 @@ newBoundTask (void) void boundTaskExiting (Task *task) { - task->stopped = rtsTrue; - #if defined(THREADED_RTS) ASSERT(osThreadId() == task->id); #endif @@ -279,6 +277,14 @@ boundTaskExiting (Task *task) endInCall(task); + // Set task->stopped, but only if this is the last call (#4850). + // Remember that we might have a worker Task that makes a foreign + // call and then a callback, so it can transform into a bound + // Task for the duration of the callback. + if (task->incall == NULL) { + task->stopped = rtsTrue; + } + debugTrace(DEBUG_sched, "task exiting"); } @@ -312,25 +318,30 @@ void taskTimeStamp (Task *task USED_IF_THREADS) { #if defined(THREADED_RTS) - Ticks currentElapsedTime, currentUserTime, elapsedGCTime; + Ticks currentElapsedTime, currentUserTime; currentUserTime = getThreadCPUTime(); currentElapsedTime = getProcessElapsedTime(); - // XXX this is wrong; we want elapsed GC time since the - // Task started. - elapsedGCTime = stat_getElapsedGCTime(); - - task->mut_time = + task->mut_time = currentUserTime - task->muttimestart - task->gc_time; task->mut_etime = - currentElapsedTime - task->elapsedtimestart - elapsedGCTime; + currentElapsedTime - task->elapsedtimestart - task->gc_etime; + if (task->gc_time < 0) { task->gc_time = 0; } + if (task->gc_etime < 0) { task->gc_etime = 0; } if (task->mut_time < 0) { task->mut_time = 0; } if (task->mut_etime < 0) { task->mut_etime = 0; } #endif } +void +taskDoneGC (Task *task, Ticks cpu_time, Ticks elapsed_time) +{ + task->gc_time += cpu_time; + task->gc_etime += elapsed_time; +} + #if defined(THREADED_RTS) void @@ -348,6 +359,19 @@ workerTaskStop (Task *task) #endif +#ifdef DEBUG + +static void *taskId(Task *task) +{ +#ifdef THREADED_RTS + return (void *)task->id; +#else + return (void *)task; +#endif +} + +#endif + #if defined(THREADED_RTS) static void OSThreadProcAttr @@ -415,22 +439,13 @@ interruptWorkerTask (Task *task) ASSERT(osThreadId() != task->id); // seppuku not allowed ASSERT(task->incall->suspended_tso); // use this only for FFI calls interruptOSThread(task->id); - debugTrace(DEBUG_sched, "interrupted worker task %lu", task->id); + debugTrace(DEBUG_sched, "interrupted worker task %p", taskId(task)); } #endif /* THREADED_RTS */ #ifdef DEBUG -static void *taskId(Task *task) -{ -#ifdef THREADED_RTS - return (void *)task->id; -#else - return (void *)task; -#endif -} - void printAllTasks(void); void