From: sof Date: Sat, 13 Apr 2002 05:25:38 +0000 (+0000) Subject: [project @ 2002-04-13 05:25:38 by sof] X-Git-Tag: Approx_11550_changesets_converted~2152 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=b53a7735911938f8cdf1cf9b4d8c4c5f5666957a;p=ghc-hetmet.git [project @ 2002-04-13 05:25:38 by sof] yieldToReturningWorker(): once yielded to a returning worker, thread now directly waits for capability to become available again (via waitForWorkCapability()) -- simplifies Cap. grabbing 'logic' in the Scheduler. grabReturnCapability(): assume pMutex is held upon entry. --- diff --git a/ghc/rts/Capability.c b/ghc/rts/Capability.c index 638dd4a..1f0d7ff 100644 --- a/ghc/rts/Capability.c +++ b/ghc/rts/Capability.c @@ -214,13 +214,13 @@ void releaseCapability(Capability* cap * Function: grabReturnCapability(Capability**) * * Purpose: when an OS thread returns from an external call, - * it calls grabReturningCapability() (via Schedule.resumeThread()) + * it calls grabReturnCapability() (via Schedule.resumeThread()) * to wait for permissions to enter the RTS & communicate the - * result of the ext. call back to the Haskell thread that + * result of the external call back to the Haskell thread that * made it. * - * Pre-condition: pMutex isn't held. - * Post-condition: pMutex is held and a capability has + * Pre-condition: pMutex is held. + * Post-condition: pMutex is still held and a capability has * been assigned to the worker thread. */ void @@ -228,7 +228,6 @@ grabReturnCapability(Mutex* pMutex, Capability** pCap) { IF_DEBUG(scheduler, fprintf(stderr,"worker (%ld): returning, waiting for lock.\n", osThreadId())); - ACQUIRE_LOCK(pMutex); rts_n_waiting_workers++; IF_DEBUG(scheduler, fprintf(stderr,"worker (%ld): returning; workers waiting: %d\n", @@ -276,6 +275,8 @@ yieldToReturningWorker(Mutex* pMutex, Capability* cap) /* Re-grab the mutex */ ACQUIRE_LOCK(pMutex); + /* And wait for work */ + waitForWorkCapability(pMutex, cap, rtsFalse); } return; }