summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rts/Schedule.c13
-rw-r--r--rts/Task.c2
-rw-r--r--rts/Task.h5
3 files changed, 18 insertions, 2 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index adf2b5cb39..7f8ced6f3e 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -1802,6 +1802,10 @@ forkProcess(HsStablePtr *entry
ACQUIRE_LOCK(&capabilities[i]->lock);
}
+#ifdef THREADED_RTS
+ ACQUIRE_LOCK(&all_tasks_mutex);
+#endif
+
stopTimer(); // See #4074
#if defined(TRACING)
@@ -1823,13 +1827,18 @@ forkProcess(HsStablePtr *entry
releaseCapability_(capabilities[i],rtsFalse);
RELEASE_LOCK(&capabilities[i]->lock);
}
+
+#ifdef THREADED_RTS
+ RELEASE_LOCK(&all_tasks_mutex);
+#endif
+
boundTaskExiting(task);
// just return the pid
return pid;
} else { // child
-
+
#if defined(THREADED_RTS)
initMutex(&sched_mutex);
initMutex(&sm_mutex);
@@ -1839,6 +1848,8 @@ forkProcess(HsStablePtr *entry
for (i=0; i < n_capabilities; i++) {
initMutex(&capabilities[i]->lock);
}
+
+ initMutex(&all_tasks_mutex);
#endif
#ifdef TRACING
diff --git a/rts/Task.c b/rts/Task.c
index e191bd0d8c..842ad84a89 100644
--- a/rts/Task.c
+++ b/rts/Task.c
@@ -39,7 +39,7 @@ static Task * allocTask (void);
static Task * newTask (rtsBool);
#if defined(THREADED_RTS)
-static Mutex all_tasks_mutex;
+Mutex all_tasks_mutex;
#endif
/* -----------------------------------------------------------------------------
diff --git a/rts/Task.h b/rts/Task.h
index cf70256326..8dab0a2fcf 100644
--- a/rts/Task.h
+++ b/rts/Task.h
@@ -171,6 +171,11 @@ isBoundTask (Task *task)
//
extern Task *all_tasks;
+// The all_tasks list is protected by the all_tasks_mutex
+#if defined(THREADED_RTS)
+extern Mutex all_tasks_mutex;
+#endif
+
// Start and stop the task manager.
// Requires: sched_mutex.
//