Commit 788897b6 authored by sof's avatar sof
Browse files

[project @ 2003-07-16 17:40:38 by sof]

- change prototype of async proc calls to

      typedef int (*DoProcProc)(void *param);

  i.e., have the proc return a result. Turned out that almost all
  uses of the primop ended up encoding a result via their 'param'.

- when adding new I/O requests, shorten the time the IOManager
  lock is held. Helps to keep down the size of the thread pool.
parent 3a3acbf4
......@@ -205,7 +205,7 @@ start:
*/
tso->block_info.async_result->len = completedTable[i].len;
tso->block_info.async_result->errCode = completedTable[i].errCode;
/* Drop the matched TSO from blocked_queue */
if (prev) {
prev->link = tso->link;
......
......@@ -120,8 +120,7 @@ IOWorkerProc(PVOID param)
/* The procedure is assumed to encode result + success/failure
* via its param.
*/
work->workData.procData.proc(work->workData.procData.param);
errCode=0;
errCode=work->workData.procData.proc(work->workData.procData.param);
} else {
errCode=1;
}
......@@ -234,9 +233,11 @@ AddIORequest ( int fd,
#endif
if ( ioMan->workersIdle == 0 ) {
ioMan->numWorkers++;
LeaveCriticalSection(&ioMan->manLock);
NewIOWorkerThread(ioMan);
} else {
LeaveCriticalSection(&ioMan->manLock);
}
LeaveCriticalSection(&ioMan->manLock);
if (SubmitWork(ioMan->workQueue,wItem)) {
return wItem->requestID;
......@@ -263,11 +264,16 @@ AddDelayRequest ( unsigned int msecs,
wItem->requestID = ioMan->requestID++;
EnterCriticalSection(&ioMan->manLock);
#if 0
fprintf(stderr, "AddDelayRequest: %d\n", ioMan->workersIdle); fflush(stderr);
#endif
if ( ioMan->workersIdle == 0 ) {
ioMan->numWorkers++;
LeaveCriticalSection(&ioMan->manLock);
NewIOWorkerThread(ioMan);
} else {
LeaveCriticalSection(&ioMan->manLock);
}
LeaveCriticalSection(&ioMan->manLock);
if (SubmitWork(ioMan->workQueue,wItem)) {
return wItem->requestID;
......@@ -296,11 +302,16 @@ AddProcRequest ( void* proc,
wItem->requestID = ioMan->requestID++;
EnterCriticalSection(&ioMan->manLock);
#if 0
fprintf(stderr, "AddProcRequest: %d\n", ioMan->workersIdle); fflush(stderr);
#endif
if ( ioMan->workersIdle == 0 ) {
ioMan->numWorkers++;
LeaveCriticalSection(&ioMan->manLock);
NewIOWorkerThread(ioMan);
} else {
LeaveCriticalSection(&ioMan->manLock);
}
LeaveCriticalSection(&ioMan->manLock);
if (SubmitWork(ioMan->workQueue,wItem)) {
return wItem->requestID;
......
......@@ -37,7 +37,12 @@ typedef void (*CompletionProc)(unsigned int requestID,
void* buf,
int errCode);
typedef void (*DoProcProc)(void *param);
/*
* Asynchronous procedure calls executed by a worker thread
* take a generic state argument pointer and return an int by
* default.
*/
typedef int (*DoProcProc)(void *param);
typedef union workData {
struct {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment