[project @ 2002-02-15 22:14:27 by sof]
authorsof <unknown>
Fri, 15 Feb 2002 22:15:09 +0000 (22:15 +0000)
committersof <unknown>
Fri, 15 Feb 2002 22:15:09 +0000 (22:15 +0000)
Extra arg to suspendThread() and resumeThread(); controls whether an external call is concurrent or not

ghc/includes/StgMacros.h
ghc/rts/Interpreter.c
ghc/rts/Schedule.c

index aeb9f10..711db95 100644 (file)
@@ -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
 
index 86c152f..95ddc48 100644 (file)
@@ -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;
               }
index b3d3446..47be2cc 100644 (file)
@@ -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