X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FRtsAPI.c;h=0a6b42ed3b577195e75b14f424d784b74b7ae1c6;hb=ab3d1f285cef784138d99e70f7359ea6e67f6c25;hp=2052f3d4f01a5cfd1916f07d3659941e8cfd3cad;hpb=20593d1d1cf47050d9430895a1c2ada6c39dfb98;p=ghc-hetmet.git diff --git a/ghc/rts/RtsAPI.c b/ghc/rts/RtsAPI.c index 2052f3d..0a6b42e 100644 --- a/ghc/rts/RtsAPI.c +++ b/ghc/rts/RtsAPI.c @@ -1,5 +1,4 @@ /* ---------------------------------------------------------------------------- - * $Id: RtsAPI.c,v 1.50 2003/11/12 17:49:08 sof 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" @@ -200,9 +199,9 @@ rts_mkString (char *s) HaskellObj rts_apply (HaskellObj f, HaskellObj arg) { - StgClosure *ap; + StgThunk *ap; - ap = (StgClosure *)allocate(sizeofW(StgClosure) + 2); + ap = (StgThunk *)allocate(sizeofW(StgThunk) + 2); SET_HDR(ap, (StgInfoTable *)&stg_ap_2_upd_info, CCS_SYSTEM); ap->payload[0] = f; ap->payload[1] = arg; @@ -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); @@ -479,13 +479,13 @@ rts_checkSchedStatus ( char* site, SchedulerStatus rc ) case Success: return; case Killed: - prog_belch("%s: uncaught exception",site); + errorBelch("%s: uncaught exception",site); stg_exit(EXIT_FAILURE); case Interrupted: - prog_belch("%s: interrupted", site); + errorBelch("%s: interrupted", site); stg_exit(EXIT_FAILURE); default: - prog_belch("%s: Return code (%d) not ok",(site),(rc)); + errorBelch("%s: Return code (%d) not ok",(site),(rc)); stg_exit(EXIT_FAILURE); } } @@ -494,13 +494,15 @@ void rts_lock() { #ifdef RTS_SUPPORTS_THREADS - ACQUIRE_LOCK(&sched_mutex); + ACQUIRE_LOCK(&sched_mutex); - // we request to get the capability immediately, in order to - // a) stop other threads from using allocate() - // b) wake the current worker thread from awaitEvent() - // (so that a thread started by rts_eval* will start immediately) - grabReturnCapability(&sched_mutex,&rtsApiCapability); + // we request to get the capability immediately, in order to + // a) stop other threads from using allocate() + // 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 } @@ -508,8 +510,9 @@ void rts_unlock() { #ifdef RTS_SUPPORTS_THREADS - if(rtsApiCapability) + if (rtsApiCapability) { releaseCapability(rtsApiCapability); + } rtsApiCapability = NULL; RELEASE_LOCK(&sched_mutex); #endif