From d262f6f57648e939f8ec4a2c12e26b65ade923fe Mon Sep 17 00:00:00 2001 From: simonmar Date: Fri, 27 Feb 2004 15:58:54 +0000 Subject: [PATCH] [project @ 2004-02-27 15:58:54 by simonmar] redo the condition-cache hack --- ghc/rts/Schedule.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index b73f530..869dd38 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -1,5 +1,5 @@ /* --------------------------------------------------------------------------- - * $Id: Schedule.c,v 1.190 2004/02/27 15:56:25 simonmar Exp $ + * $Id: Schedule.c,v 1.191 2004/02/27 15:58:54 simonmar Exp $ * * (c) The GHC Team, 1998-2003 * @@ -1965,9 +1965,11 @@ scheduleThread(StgTSO* tso) } #if defined(RTS_SUPPORTS_THREADS) -static Condition *bound_cond_cache = NULL; +static Condition bound_cond_cache; +static int bound_cond_cache_full = 0; #endif + SchedulerStatus scheduleWaitThread(StgTSO* tso, /*[out]*/HaskellObj* ret, Capability *initialCapability) @@ -1983,9 +1985,9 @@ scheduleWaitThread(StgTSO* tso, /*[out]*/HaskellObj* ret, // Allocating a new condition for each thread is expensive, so we // cache one. This is a pretty feeble hack, but it helps speed up // consecutive call-ins quite a bit. - if (bound_cond_cache != NULL) { - m->bound_thread_cond = *bound_cond_cache; - bound_cond_cache = NULL; + if (bound_cond_cache_full) { + m->bound_thread_cond = bound_cond_cache; + bound_cond_cache_full = 0; } else { initCondition(&m->bound_thread_cond); } @@ -2080,7 +2082,6 @@ initScheduler(void) #endif RELEASE_LOCK(&sched_mutex); - } void @@ -2125,8 +2126,9 @@ waitThread_(StgMainThread* m, Capability *initialCapability) #if defined(RTS_SUPPORTS_THREADS) // Free the condition variable, returning it to the cache if possible. - if (bound_cond_cache == NULL) { - *bound_cond_cache = m->bound_thread_cond; + if (!bound_cond_cache_full) { + bound_cond_cache = m->bound_thread_cond; + bound_cond_cache_full = 1; } else { closeCondition(&m->bound_thread_cond); } -- 1.7.10.4