/* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.129 2001/11/28 15:42:05 simonmar Exp $
+ * $Id: GC.c,v 1.130 2002/02/18 13:26:12 sof Exp $
*
* (c) The GHC Team 1998-1999
*
- free from-space in each step, and set from-space = to-space.
+ Locks held: sched_mutex
+
-------------------------------------------------------------------------- */
void
// Reset the nursery
resetNurseries();
+ // let go of lock (so that it can be re-grabbed below).
+ RELEASE_LOCK(&sched_mutex);
+
// start any pending finalizers
scheduleFinalizers(old_weak_ptr_list);
// send exceptions to any threads which were about to die
resurrectThreads(resurrected_threads);
+ ACQUIRE_LOCK(&sched_mutex);
+
// Update the stable pointer hash table.
updateStablePtrTable(major_gc);
/* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.130 2002/02/16 00:30:05 sof Exp $
+ * $Id: Schedule.c,v 1.131 2002/02/18 13:26:13 sof Exp $
*
* (c) The GHC Team, 1998-2000
*
/* 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) ) {
#if defined(RTS_SUPPORTS_THREADS)
IF_DEBUG(scheduler,sched_belch("doing GC"));
#endif
- RELEASE_LOCK(&sched_mutex);
GarbageCollect(GetRoots,rtsFalse);
- ACQUIRE_LOCK(&sched_mutex);
ready_to_gc = rtsFalse;
#ifdef SMP
broadcastCondition(&gc_pending_cond);
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
void
performGCWithRoots(void (*get_roots)(evac_fn))
{
+ ACQUIRE_LOCK(&sched_mutex);
extra_roots = get_roots;
GarbageCollect(AllRoots,rtsFalse);
+ RELEASE_LOCK(&sched_mutex);
}
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: Weak.c,v 1.20 2001/11/26 16:54:22 simonmar Exp $
+ * $Id: Weak.c,v 1.21 2002/02/18 13:26:13 sof Exp $
*
* (c) The GHC Team, 1998-1999
*
* The weak pointer object itself may not be alive - i.e. we may be
* looking at either an object in from-space or one in to-space. It
* doesn't really matter either way.
+ *
+ * Pre-condition: sched_mutex _not_ held.
*/
void