From: simonmar Date: Wed, 27 Apr 2005 12:52:52 +0000 (+0000) Subject: [project @ 2005-04-27 12:52:52 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~658 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=e1f6c7463cc0184ca1bf31712ce250764f3a43f9;p=ghc-hetmet.git [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. --- 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