[project @ 2002-02-28 08:53:58 by sof]
[ghc-hetmet.git] / ghc / rts / Schedule.c
index 47be2cc..4197f58 100644 (file)
@@ -1,5 +1,5 @@
 /* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.129 2002/02/15 22:15:09 sof Exp $
+ * $Id: Schedule.c,v 1.132 2002/02/18 17:27:24 sof Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -595,9 +595,7 @@ schedule( void )
        /* and SMP mode ..? */
        releaseCapability(cap);
 #endif
-       RELEASE_LOCK(&sched_mutex);
        GarbageCollect(GetRoots,rtsTrue);
-       ACQUIRE_LOCK(&sched_mutex);
        if (   EMPTY_QUEUE(blocked_queue_hd)
            && EMPTY_RUN_QUEUE()
            && EMPTY_QUEUE(sleeping_queue) ) {
@@ -1428,7 +1426,12 @@ void deleteAllThreads ( void )
  * ------------------------------------------------------------------------- */
    
 StgInt
-suspendThread( StgRegTable *reg, rtsBool concCall )
+suspendThread( StgRegTable *reg, 
+              rtsBool concCall
+#if !defined(RTS_SUPPORTS_THREADS)
+              STG_UNUSED
+#endif
+              )
 {
   nat tok;
   Capability *cap;
@@ -1478,7 +1481,12 @@ suspendThread( StgRegTable *reg, rtsBool concCall )
 }
 
 StgRegTable *
-resumeThread( StgInt tok, rtsBool concCall )
+resumeThread( StgInt tok,
+             rtsBool concCall
+#if !defined(RTS_SUPPORTS_THREADS)
+              STG_UNUSED
+#endif
+             )
 {
   StgTSO *tso, **prev;
   Capability *cap;
@@ -2318,13 +2326,18 @@ void (*extra_roots)(evac_fn);
 void
 performGC(void)
 {
+  /* Obligated to hold this lock upon entry */
+  ACQUIRE_LOCK(&sched_mutex);
   GarbageCollect(GetRoots,rtsFalse);
+  RELEASE_LOCK(&sched_mutex);
 }
 
 void
 performMajorGC(void)
 {
+  ACQUIRE_LOCK(&sched_mutex);
   GarbageCollect(GetRoots,rtsTrue);
+  RELEASE_LOCK(&sched_mutex);
 }
 
 static void
@@ -2337,8 +2350,10 @@ AllRoots(evac_fn evac)
 void
 performGCWithRoots(void (*get_roots)(evac_fn))
 {
+  ACQUIRE_LOCK(&sched_mutex);
   extra_roots = get_roots;
   GarbageCollect(AllRoots,rtsFalse);
+  RELEASE_LOCK(&sched_mutex);
 }
 
 /* -----------------------------------------------------------------------------