From e1f6c7463cc0184ca1bf31712ce250764f3a43f9 Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 27 Apr 2005 12:52:52 +0000 Subject: [PATCH] [project @ 2005-04-27 12:52:52 by simonmar] expandTaskTable: we need to update the hash table too (found by: Valgrind :-) initTaskManager: take into account -N flag when sizing the initial task table. --- ghc/rts/Task.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ghc/rts/Task.c b/ghc/rts/Task.c index 8e0a279..46cfa26 100644 --- a/ghc/rts/Task.c +++ b/ghc/rts/Task.c @@ -28,7 +28,8 @@ TaskInfo* taskTable; static nat taskTableSize; -HashTable *taskHash; // maps OSThreadID to TaskInfo* +// maps OSThreadID to TaskInfo* +HashTable *taskHash; nat taskCount; static nat tasksRunning; @@ -43,7 +44,12 @@ initTaskManager (void) static int initialized = 0; if (!initialized) { +#if defined(SMP) + taskTableSize = stg_max(INIT_TASK_TABLE_SIZE, + RtsFlags.ParFlags.nNodes * 2); +#else taskTableSize = INIT_TASK_TABLE_SIZE; +#endif taskTable = stgMallocBytes( taskTableSize * sizeof(TaskInfo), "initTaskManager"); @@ -62,9 +68,17 @@ initTaskManager (void) static void expandTaskTable (void) { + nat i; + taskTableSize *= 2; taskTable = stgReallocBytes(taskTable, taskTableSize * sizeof(TaskInfo), "expandTaskTable"); + + /* Have to update the hash table now... */ + for (i = 0; i < taskCount; i++) { + removeHashTable( taskHash, taskTable[i].id, NULL ); + insertHashTable( taskHash, taskTable[i].id, &taskTable[i] ); + } } void -- 1.7.10.4