From: sof Date: Fri, 15 Feb 2002 22:15:09 +0000 (+0000) Subject: [project @ 2002-02-15 22:14:27 by sof] X-Git-Tag: Approximately_9120_patches~22 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=9d70000eec0ed66e266922f1fcfb5f028f9f1d58;p=ghc-hetmet.git [project @ 2002-02-15 22:14:27 by sof] Extra arg to suspendThread() and resumeThread(); controls whether an external call is concurrent or not --- diff --git a/ghc/includes/StgMacros.h b/ghc/includes/StgMacros.h index aeb9f10..711db95 100644 --- a/ghc/includes/StgMacros.h +++ b/ghc/includes/StgMacros.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgMacros.h,v 1.45 2001/12/10 18:06:50 sof Exp $ + * $Id: StgMacros.h,v 1.46 2002/02/15 22:14:27 sof Exp $ * * (c) The GHC Team, 1998-1999 * @@ -810,20 +810,20 @@ LoadThreadState (void) * Suspending/resuming threads for doing external C-calls (_ccall_GC). * These functions are defined in rts/Schedule.c. */ -StgInt suspendThread ( StgRegTable * ); -StgRegTable * resumeThread ( StgInt ); +StgInt suspendThread ( StgRegTable *, rtsBool); +StgRegTable * resumeThread ( StgInt, rtsBool ); -#define SUSPEND_THREAD(token) \ +#define SUSPEND_THREAD(token,threaded) \ SaveThreadState(); \ - token = suspendThread(BaseReg); + token = suspendThread(BaseReg,threaded); #ifdef SMP -#define RESUME_THREAD(token) \ - BaseReg = resumeThread(token); \ +#define RESUME_THREAD(token,threaded) \ + BaseReg = resumeThread(token,threaded); \ LoadThreadState(); #else -#define RESUME_THREAD(token) \ - (void)resumeThread(token); \ +#define RESUME_THREAD(token,threaded) \ + (void)resumeThread(token,threaded); \ LoadThreadState(); #endif diff --git a/ghc/rts/Interpreter.c b/ghc/rts/Interpreter.c index 86c152f..95ddc48 100644 --- a/ghc/rts/Interpreter.c +++ b/ghc/rts/Interpreter.c @@ -5,8 +5,8 @@ * Copyright (c) 1994-2000. * * $RCSfile: Interpreter.c,v $ - * $Revision: 1.33 $ - * $Date: 2002/01/24 02:15:19 $ + * $Revision: 1.34 $ + * $Date: 2002/02/15 22:15:08 $ * ---------------------------------------------------------------------------*/ #if !defined(SMP) @@ -780,9 +780,9 @@ StgThreadReturnCode interpretBCO ( Capability* cap ) int o_itbl = BCO_NEXT; void(*marshall_fn)(void*) = (void (*)(void*))BCO_LIT(o_itbl); SAVE_STACK_POINTERS; - tok = suspendThread(&cap->r); + tok = suspendThread(&cap->r,rtsFalse); marshall_fn ( (void*)(& StackWord(0) ) ); - cap = (Capability *)((void *)resumeThread(tok) - sizeof(StgFunTable)); + cap = (Capability *)((void *)resumeThread(tok,rtsFalse) - sizeof(StgFunTable)); LOAD_STACK_POINTERS; goto nextInsn; } diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index b3d3446..47be2cc 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -1,5 +1,5 @@ /* --------------------------------------------------------------------------- - * $Id: Schedule.c,v 1.128 2002/02/15 20:58:14 sof Exp $ + * $Id: Schedule.c,v 1.129 2002/02/15 22:15:09 sof Exp $ * * (c) The GHC Team, 1998-2000 * @@ -1428,7 +1428,7 @@ void deleteAllThreads ( void ) * ------------------------------------------------------------------------- */ StgInt -suspendThread( StgRegTable *reg ) +suspendThread( StgRegTable *reg, rtsBool concCall ) { nat tok; Capability *cap; @@ -1457,7 +1457,7 @@ suspendThread( StgRegTable *reg ) /* Hand back capability */ releaseCapability(cap); -#if defined(RTS_SUPPORTS_THREADS) && !defined(SMP) +#if defined(RTS_SUPPORTS_THREADS) /* Preparing to leave the RTS, so ensure there's a native thread/task waiting to take over. @@ -1466,7 +1466,9 @@ suspendThread( StgRegTable *reg ) there's no need to create a new task). */ IF_DEBUG(scheduler, sched_belch("worker thread (%d): leaving RTS", tok)); - startTask(taskStart); + if (concCall) { + startTask(taskStart); + } #endif /* Other threads _might_ be available for execution; signal this */ @@ -1476,14 +1478,18 @@ suspendThread( StgRegTable *reg ) } StgRegTable * -resumeThread( StgInt tok ) +resumeThread( StgInt tok, rtsBool concCall ) { StgTSO *tso, **prev; Capability *cap; #if defined(RTS_SUPPORTS_THREADS) /* Wait for permission to re-enter the RTS with the result. */ - grabReturnCapability(&sched_mutex, &cap); + if ( concCall ) { + grabReturnCapability(&sched_mutex, &cap); + } else { + grabCapability(&cap); + } #else grabCapability(&cap); #endif