Skip to content

Commit

Permalink
[project @ 2002-02-15 22:14:27 by sof]
Browse files Browse the repository at this point in the history
Extra arg to suspendThread() and resumeThread(); controls whether an external call is concurrent or not
  • Loading branch information
sof committed Feb 15, 2002
1 parent d95869c commit 9d70000
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
18 changes: 9 additions & 9 deletions ghc/includes/StgMacros.h
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions ghc/rts/Interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
18 changes: 12 additions & 6 deletions ghc/rts/Schedule.c
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -1428,7 +1428,7 @@ void deleteAllThreads ( void )
* ------------------------------------------------------------------------- */

StgInt
suspendThread( StgRegTable *reg )
suspendThread( StgRegTable *reg, rtsBool concCall )
{
nat tok;
Capability *cap;
Expand Down Expand Up @@ -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.
Expand All @@ -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 */
Expand All @@ -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
Expand Down

0 comments on commit 9d70000

Please sign in to comment.