X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FSchedule.c;h=4197f58ccdceabf2b15737ec886aef98c41a1a77;hb=354f17ec86e2e11f2e77a159916b2e7be74979c9;hp=b3d34463d39746b91d28eb5ae25787d3e68b4a8d;hpb=b77098031265b55b28ddf6f3fe89c429c66cceb7;p=ghc-hetmet.git diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index b3d3446..4197f58 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -1,5 +1,5 @@ /* --------------------------------------------------------------------------- - * $Id: Schedule.c,v 1.128 2002/02/15 20:58:14 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 ) +suspendThread( StgRegTable *reg, + rtsBool concCall +#if !defined(RTS_SUPPORTS_THREADS) + STG_UNUSED +#endif + ) { nat tok; Capability *cap; @@ -1457,7 +1460,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 +1469,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 +1481,23 @@ suspendThread( StgRegTable *reg ) } StgRegTable * -resumeThread( StgInt tok ) +resumeThread( StgInt tok, + rtsBool concCall +#if !defined(RTS_SUPPORTS_THREADS) + STG_UNUSED +#endif + ) { 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 @@ -2312,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 @@ -2331,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); } /* -----------------------------------------------------------------------------