[commit: ghc] ghc-7.8: Acquire all_tasks_mutex in forkProcess (1fc3baf)

git at git.haskell.org git at git.haskell.org
Mon Aug 4 13:21:06 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.8
Link       : http://ghc.haskell.org/trac/ghc/changeset/1fc3baf3476a0105b10598c56d4efe3831fb5300/ghc

>---------------------------------------------------------------

commit 1fc3baf3476a0105b10598c56d4efe3831fb5300
Author: Edsko de Vries <edsko at well-typed.com>
Date:   Sun Jul 13 15:19:45 2014 -0500

    Acquire all_tasks_mutex in forkProcess
    
    Summary: (for the same reason that we acquire all the other mutexes)
    
    Test Plan: validate
    
    Reviewers: simonmar, austin, duncan
    
    Reviewed By: simonmar, austin, duncan
    
    Subscribers: simonmar, relrod, carter
    
    Differential Revision: https://phabricator.haskell.org/D60
    
    (cherry picked from commit 16403f0d182d2d3d0b1fbe5ad778ead4bfcb7e16)


>---------------------------------------------------------------

1fc3baf3476a0105b10598c56d4efe3831fb5300
 rts/Schedule.c | 11 +++++++++++
 rts/Task.c     |  2 +-
 rts/Task.h     |  5 +++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/rts/Schedule.c b/rts/Schedule.c
index adf2b5c..7f8ced6 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,6 +1827,11 @@ 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
@@ -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 e191bd0..842ad84 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 cf70256..8dab0a2 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.
 //



More information about the ghc-commits mailing list