X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FTask.c;h=a5de804418ab2eeefbfc16bcad39e3fbc4a8c540;hb=26f4bfc82f2b2359259578e9c54d476fc2de650f;hp=8a289be0078f8a4d68af8b532a8ef9b219a74145;hpb=ed30194937e0562e62da3e71f9da8585ac6cf477;p=ghc-hetmet.git diff --git a/rts/Task.c b/rts/Task.c index 8a289be..a5de804 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -63,8 +63,10 @@ initTaskManager (void) if (!tasksInitialized) { taskCount = 0; tasksInitialized = 1; -#if defined(THREADED_RTS) && !defined(MYTASK_USE_TLV) +#if defined(THREADED_RTS) +#if !defined(MYTASK_USE_TLV) newThreadLocalKey(¤tTaskKey); +#endif initMutex(&all_tasks_mutex); #endif } @@ -268,8 +270,6 @@ newBoundTask (void) void boundTaskExiting (Task *task) { - task->stopped = rtsTrue; - #if defined(THREADED_RTS) ASSERT(osThreadId() == task->id); #endif @@ -277,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"); } @@ -346,6 +354,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 @@ -407,19 +428,19 @@ startWorkerTask (Capability *cap) RELEASE_LOCK(&task->lock); } +void +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 %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