[project @ 2001-02-06 12:09:42 by sewardj]
authorsewardj <unknown>
Tue, 6 Feb 2001 12:09:42 +0000 (12:09 +0000)
committersewardj <unknown>
Tue, 6 Feb 2001 12:09:42 +0000 (12:09 +0000)
Check the context_switch flag and yield if set, so that interpreted
code behaves properly in a multi(haskell)threaded environment.

ghc/rts/Interpreter.c

index 99f126b..cdd9660 100644 (file)
@@ -5,8 +5,8 @@
  * Copyright (c) 1994-2000.
  *
  * $RCSfile: Interpreter.c,v $
- * $Revision: 1.15 $
- * $Date: 2001/02/06 12:02:05 $
+ * $Revision: 1.16 $
+ * $Date: 2001/02/06 12:09:42 $
  * ---------------------------------------------------------------------------*/
 
 #ifdef GHCI
@@ -383,7 +383,16 @@ StgThreadReturnCode interpretBCO ( Capability* cap )
              cap->rCurrentTSO->what_next = ThreadEnterInterp;
              RETURN(StackOverflow);
           }
+
+          /* Context-switch check */
+          if (context_switch) {
+             iSp--;
+             StackWord(0) = (W_)obj;
+             cap->rCurrentTSO->what_next = ThreadEnterInterp;
+             RETURN(ThreadYielding);
+         }
  
+
 #         ifdef INTERP_STATS
           it_lastopc = 0; /* no opcode */
 #         endif