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.
* Function: grabReturnCapability(Capability**)
*
* Purpose: when an OS thread returns from an external call,
* 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
* 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
- * 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
* been assigned to the worker thread.
*/
void
{
IF_DEBUG(scheduler,
fprintf(stderr,"worker (%ld): returning, waiting for lock.\n", osThreadId()));
{
IF_DEBUG(scheduler,
fprintf(stderr,"worker (%ld): returning, waiting for lock.\n", osThreadId()));
rts_n_waiting_workers++;
IF_DEBUG(scheduler,
fprintf(stderr,"worker (%ld): returning; workers waiting: %d\n",
rts_n_waiting_workers++;
IF_DEBUG(scheduler,
fprintf(stderr,"worker (%ld): returning; workers waiting: %d\n",
/* Re-grab the mutex */
ACQUIRE_LOCK(pMutex);
/* Re-grab the mutex */
ACQUIRE_LOCK(pMutex);
+ /* And wait for work */
+ waitForWorkCapability(pMutex, cap, rtsFalse);