Move allocation of spark pools into initCapability
authorDuncan Coutts <duncan@well-typed.com>
Mon, 6 Jun 2011 09:32:33 +0000 (10:32 +0100)
committerDuncan Coutts <duncan@well-typed.com>
Mon, 18 Jul 2011 15:31:14 +0000 (16:31 +0100)
Rather than a separate phase of initSparkPools. It means all the spark
stuff for a capability is initialisaed at the same time, which is then
becomes a good place to stick an initial spark trace event.

rts/Capability.c
rts/Schedule.c
rts/Sparks.c
rts/Sparks.h

index 410d3d0..d8c3b2d 100644 (file)
@@ -232,6 +232,7 @@ initCapability( Capability *cap, nat i )
     cap->returning_tasks_hd = NULL;
     cap->returning_tasks_tl = NULL;
     cap->inbox              = (Message*)END_TSO_QUEUE;
+    cap->sparks             = allocSparkPool();
     cap->spark_stats.created    = 0;
     cap->spark_stats.dud        = 0;
     cap->spark_stats.overflowed = 0;
index 5c94e20..2222200 100644 (file)
@@ -2010,10 +2010,6 @@ initScheduler(void)
 
   initTaskManager();
 
-#if defined(THREADED_RTS)
-  initSparkPools();
-#endif
-
   RELEASE_LOCK(&sched_mutex);
 
 #if defined(THREADED_RTS)
index 26b8199..6ce2e68 100644 (file)
 
 #if defined(THREADED_RTS)
 
-void
-initSparkPools( void )
+SparkPool *
+allocSparkPool( void )
 {
-    /* walk over the capabilities, allocating a spark pool for each one */
-    nat i;
-    for (i = 0; i < n_capabilities; i++) {
-      capabilities[i].sparks = newWSDeque(RtsFlags.ParFlags.maxLocalSparks);
-    }
+    return newWSDeque(RtsFlags.ParFlags.maxLocalSparks);
 }
 
 void
index 7db6018..e381dd5 100644 (file)
@@ -30,7 +30,7 @@ typedef struct {
 typedef WSDeque SparkPool;
 
 // Initialisation
-void initSparkPools (void);
+SparkPool *allocSparkPool (void);
 
 // Take a spark from the "write" end of the pool.  Can be called
 // by the pool owner only.