diff options
author | sof <unknown> | 2003-07-16 17:40:39 +0000 |
---|---|---|
committer | sof <unknown> | 2003-07-16 17:40:39 +0000 |
commit | 788897b6bdcc4d3275a7e72d501d60eddf8abe49 (patch) | |
tree | c2f10542d1535f467d89c559104a0be8997720b5 /ghc/rts/win32 | |
parent | 3a3acbf43d8b4dd25ebbd22ca159481d224486bb (diff) | |
download | haskell-788897b6bdcc4d3275a7e72d501d60eddf8abe49.tar.gz |
[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.
Diffstat (limited to 'ghc/rts/win32')
-rw-r--r-- | ghc/rts/win32/AsyncIO.c | 2 | ||||
-rw-r--r-- | ghc/rts/win32/IOManager.c | 21 | ||||
-rw-r--r-- | ghc/rts/win32/IOManager.h | 7 |
3 files changed, 23 insertions, 7 deletions
diff --git a/ghc/rts/win32/AsyncIO.c b/ghc/rts/win32/AsyncIO.c index 00866963e1..bc153a9446 100644 --- a/ghc/rts/win32/AsyncIO.c +++ b/ghc/rts/win32/AsyncIO.c @@ -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; diff --git a/ghc/rts/win32/IOManager.c b/ghc/rts/win32/IOManager.c index 42eba0092c..35cca1b6b8 100644 --- a/ghc/rts/win32/IOManager.c +++ b/ghc/rts/win32/IOManager.c @@ -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; diff --git a/ghc/rts/win32/IOManager.h b/ghc/rts/win32/IOManager.h index cbdda44a69..686ea6ca23 100644 --- a/ghc/rts/win32/IOManager.h +++ b/ghc/rts/win32/IOManager.h @@ -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 { |