Windows: Run Workers until empty task queue

Do not allow a worker thread to sleep until the task queue is
empty.  It is better for the running thread to pick up and process
a task then to sleep this thread and wait for another one to wake
up to perform the work.

Change-Id: I776bb9408ab054b045acb9bc003b88436cc4266b
Reviewed-on: http://gerrit.openafs.org/6626
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
This commit is contained in:
Jeffrey Altman 2012-01-29 10:37:50 -05:00 committed by Jeffrey Altman
parent 55af3387ef
commit 0f65600b67

View File

@ -700,13 +700,24 @@ AFSWorkerThread( IN PVOID Context)
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSWorkerThread Wait for queue items failed Status %08lX\n", ntStatus);
ntStatus = STATUS_SUCCESS;
}
else
{
pWorkItem = AFSRemoveWorkItem();
if( pWorkItem != NULL)
if( pWorkItem == NULL)
{
ntStatus = KeWaitForSingleObject( &pLibraryDevExt->Specific.Library.WorkerQueueHasItems,
Executive,
KernelMode,
FALSE,
NULL);
}
else
{
freeWorkItem = TRUE;
@ -802,15 +813,10 @@ AFSWorkerThread( IN PVOID Context)
ExFreePoolWithTag( pWorkItem, AFS_WORK_ITEM_TAG);
}
ntStatus = STATUS_SUCCESS;
}
}
ntStatus = KeWaitForSingleObject( &pLibraryDevExt->Specific.Library.WorkerQueueHasItems,
Executive,
KernelMode,
FALSE,
NULL);
} // worker thread loop
ClearFlag( pPoolContext->State, AFS_WORKER_INITIALIZED);
@ -868,13 +874,24 @@ AFSIOWorkerThread( IN PVOID Context)
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSIOWorkerThread Wait for queue items failed Status %08lX\n", ntStatus);
ntStatus = STATUS_SUCCESS;
}
else
{
pWorkItem = AFSRemoveIOWorkItem();
if( pWorkItem != NULL)
if( pWorkItem == NULL)
{
ntStatus = KeWaitForSingleObject( &pLibraryDevExt->Specific.Library.IOWorkerQueueHasItems,
Executive,
KernelMode,
FALSE,
NULL);
}
else
{
freeWorkItem = TRUE;
@ -930,15 +947,10 @@ AFSIOWorkerThread( IN PVOID Context)
ExFreePoolWithTag( pWorkItem, AFS_WORK_ITEM_TAG);
}
ntStatus = STATUS_SUCCESS;
}
}
ntStatus = KeWaitForSingleObject( &pLibraryDevExt->Specific.Library.IOWorkerQueueHasItems,
Executive,
KernelMode,
FALSE,
NULL);
} // worker thread loop
ClearFlag( pPoolContext->State, AFS_WORKER_INITIALIZED);