[project @ 2005-04-22 21:16:27 by simonmar]
[ghc-hetmet.git] / ghc / rts / RtsAPI.c
index c91253b..d196c91 100644 (file)
@@ -1,5 +1,4 @@
 /* ----------------------------------------------------------------------------
- * $Id: RtsAPI.c,v 1.52 2004/09/03 15:28:39 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2001
  *
@@ -9,13 +8,13 @@
 
 #include "PosixSource.h"
 #include "Rts.h"
+#include "OSThreads.h"
 #include "Storage.h"
 #include "RtsAPI.h"
 #include "SchedAPI.h"
 #include "RtsFlags.h"
 #include "RtsUtils.h"
 #include "Prelude.h"
-#include "OSThreads.h"
 #include "Schedule.h"
 #include "Capability.h"
 
@@ -431,11 +430,12 @@ rts_evalStableIO (HsStablePtr s, /*out*/HsStablePtr *ret)
     StgTSO* tso;
     StgClosure *p, *r;
     SchedulerStatus stat;
+    Capability *cap = rtsApiCapability;
+    rtsApiCapability = NULL;
     
     p = (StgClosure *)deRefStablePtr(s);
     tso = createStrictIOThread(RtsFlags.GcFlags.initialStkSize, p);
-    stat = scheduleWaitThread(tso,&r,rtsApiCapability);
-    rtsApiCapability = NULL;
+    stat = scheduleWaitThread(tso,&r,cap);
 
     if (stat == Success && ret != NULL) {
        ASSERT(r != NULL);
@@ -501,6 +501,8 @@ rts_lock()
     // b) wake the current worker thread from awaitEvent()
     //       (so that a thread started by rts_eval* will start immediately)
     waitForReturnCapability(&sched_mutex,&rtsApiCapability);
+#else
+    grabCapability(&rtsApiCapability);
 #endif
 }