X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2Fwin32%2FAwaitEvent.c;h=d1dca63df642467c3a1a23d31b663398cd10f410;hb=45252b35151fc55aa19fb6770df5ed8267639083;hp=92a84bcb965c780d25d61eb968466fd8a72fe4d8;hpb=e807565a9792b31ed02e37fd837375840be6a22f;p=ghc-hetmet.git diff --git a/ghc/rts/win32/AwaitEvent.c b/ghc/rts/win32/AwaitEvent.c index 92a84bc..d1dca63 100644 --- a/ghc/rts/win32/AwaitEvent.c +++ b/ghc/rts/win32/AwaitEvent.c @@ -1,3 +1,4 @@ +#if !defined(THREADED_RTS) /* to the end */ /* * Wait/check for external events. Periodically, the * Scheduler checks for the completion of external operations, @@ -14,33 +15,25 @@ */ #include "Rts.h" #include "Schedule.h" +#include "AwaitEvent.h" #include #include "win32/AsyncIO.h" -#if defined(RTS_SUPPORTS_THREADS) -#include "Capability.h" -#endif + +// Used to avoid calling abandonRequestWait() if we don't need to. +// Protected by sched_mutex. +static nat workerWaitingForRequests = 0; void awaitEvent(rtsBool wait) { int ret; -#ifdef RTS_SUPPORTS_THREADS - // Small optimisation: we don't want the waiting thread to wake - // up straight away just because a previous returning worker has - // called abandonRequestWait(). If the event is no longer needed, - // reset it. We must do this inside the sched_mutex. - if (!needToYieldToReturningWorker()) { - resetAbandonRequestWait(); - } -#endif - do { /* Try to de-queue completed IO requests */ - RELEASE_LOCK(&sched_mutex); + workerWaitingForRequests = 1; ret = awaitRequests(wait); - ACQUIRE_LOCK(&sched_mutex); + workerWaitingForRequests = 0; if (!ret) { return; /* still hold the lock */ } @@ -49,22 +42,10 @@ awaitEvent(rtsBool wait) // // - we were interrupted // - new threads have arrived - // - another worker wants to take over (RTS_SUPPORTS_THREADS) } while (wait && !interrupted - && run_queue_hd == END_TSO_QUEUE -#ifdef RTS_SUPPORTS_THREADS - && !needToYieldToReturningWorker() -#endif + && emptyRunQueue(&MainCapability) ); } - -#ifdef RTS_SUPPORTS_THREADS -void -wakeBlockedWorkerThread() -{ - abandonRequestWait(); -} #endif -