From b27a9869bf0bd9f0731820db26056bedf7bb18ae Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 12 Oct 2010 23:16:51 +0100 Subject: [PATCH] initialise for 1024 threads (report from Jiefie Ma). --- C/init.c | 10 +++++++--- H/Yap.h | 6 +++--- H/YapHeap.h | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/C/init.c b/C/init.c index d19b0c569..c8da8974d 100755 --- a/C/init.c +++ b/C/init.c @@ -1146,6 +1146,9 @@ InitThreadHandle(int wid) FOREIGN_ThreadHandle(wid).thread_inst_count = 0LL; #endif pthread_mutex_init(&(FOREIGN_ThreadHandle(wid).tlock), NULL); + pthread_mutex_init(&(FOREIGN_ThreadHandle(wid).tlock_status), NULL); + FOREIGN_ThreadHandle(wid).tdetach = (CELL)0; + FOREIGN_ThreadHandle(wid).cmod = (CELL)0; } #endif @@ -1197,7 +1200,7 @@ Yap_CloseScratchPad(void) #include "iglobals.h" #if defined(YAPOR) || defined(THREADS) -#define MAX_INITS MAX_WORKERS +#define MAX_INITS MAX_AGENTS #else #define MAX_INITS 1 #endif @@ -1205,7 +1208,7 @@ Yap_CloseScratchPad(void) struct worker_shared Yap_Global; #if defined(YAPOR) || defined(THREADS) -struct worker_local Yap_WLocal[MAX_WORKERS]; +struct worker_local Yap_WLocal[MAX_AGENTS]; #else struct worker_local Yap_WLocal; #endif @@ -1216,8 +1219,9 @@ InitCodes(void) int wid; #include "ihstruct.h" InitGlobal(); - for (wid = 0; wid < MAX_INITS; wid++) + for (wid = 0; wid < MAX_INITS; wid++) { InitWorker(wid); + } InitFirstWorkerThreadHandle(); /* make sure no one else can use these two atoms */ CurrentModule = 0; diff --git a/H/Yap.h b/H/Yap.h index 3f310d9c1..46f294835 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -423,10 +423,10 @@ typedef pthread_rwlock_t rwlock_t; #ifdef __alpha #include #endif -#ifdef YAPOR -#define MAX_AGENTS MAX_WORKERS -#elif defined(THREADS) +#if defined(THREADS) #define MAX_AGENTS MAX_THREADS +#elif defined(YAPOR) +#define MAX_AGENTS MAX_WORKERS #endif #endif diff --git a/H/YapHeap.h b/H/YapHeap.h index 905f08d00..fff158780 100755 --- a/H/YapHeap.h +++ b/H/YapHeap.h @@ -175,7 +175,7 @@ extern struct worker_shared Yap_Global; #define Yap_global (&Yap_Global) #if defined(YAPOR) || defined(THREADS) -extern struct worker_local Yap_WLocal[MAX_WORKERS]; +extern struct worker_local Yap_WLocal[MAX_AGENTS]; #define WL (Yap_WLocal+worker_id) #define FOREIGN_WL(wid) (Yap_WLocal+(wid)) #else