void
boundTaskExiting (Task *task)
{
- task->stopped = rtsTrue;
-
#if defined(THREADED_RTS)
ASSERT(osThreadId() == task->id);
#endif
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");
}
#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
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