[project @ 2002-04-23 06:19:06 by sof]
authorsof <unknown>
Tue, 23 Apr 2002 06:19:06 +0000 (06:19 +0000)
committersof <unknown>
Tue, 23 Apr 2002 06:19:06 +0000 (06:19 +0000)
Simplified yieldToReturningWorker(), no need to have OS thread yield

ghc/rts/Capability.c
ghc/rts/Capability.h

index 1f0d7ff..d8bdbe6 100644 (file)
@@ -259,24 +259,14 @@ grabReturnCapability(Mutex* pMutex, Capability** pCap)
  *                 been given back.
  */
 void
-yieldToReturningWorker(Mutex* pMutex, Capability* cap)
+yieldToReturningWorker(Mutex* pMutex, Capability** pCap)
 {
   if ( rts_n_waiting_workers > 0 && noCapabilities() ) {
     IF_DEBUG(scheduler,
             fprintf(stderr,"worker thread (%ld): giving up RTS token\n", osThreadId()));
-    releaseCapability(cap);
-    RELEASE_LOCK(pMutex);
-    yieldThread();
-    /* At this point, pMutex has been given up & we've 
-     * forced a thread context switch. Guaranteed to be
-     * enough for the signalled worker thread to race
-     * ahead of us?
-     */
-
-    /* Re-grab the mutex */
-    ACQUIRE_LOCK(pMutex);
+    releaseCapability(*pCap);
     /* And wait for work */
-    waitForWorkCapability(pMutex, cap, rtsFalse);
+    waitForWorkCapability(pMutex, pCap, rtsFalse);
   }
   return;
 }
index 8a3260c..cb0b09b 100644 (file)
@@ -42,7 +42,7 @@ extern nat rts_n_free_capabilities;
 extern nat rts_n_waiting_workers; /* used by Task.c to determine */
 
 extern void grabReturnCapability(Mutex* pMutex, Capability** pCap);
-extern void yieldToReturningWorker(Mutex* pMutex, Capability* cap);
+extern void yieldToReturningWorker(Mutex* pMutex, Capability** pCap);
 extern void waitForWorkCapability(Mutex* pMutex, Capability** pCap, rtsBool runnable);
 
 static inline nat getFreeCapabilities (void)