From 313dc5e53f1b046b82c8b71cad85ed8b7567d12b Mon Sep 17 00:00:00 2001 From: Gunnar Dalsnes Date: Wed, 19 Mar 2003 23:09:54 +0000 Subject: [PATCH] set thread WaitReason when blocking initial work on I/O completion svn path=/trunk/; revision=4350 --- reactos/ntoskrnl/ke/wait.c | 39 ++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/ke/wait.c b/reactos/ntoskrnl/ke/wait.c index 859c0d9db1b..4005644c11c 100644 --- a/reactos/ntoskrnl/ke/wait.c +++ b/reactos/ntoskrnl/ke/wait.c @@ -103,7 +103,8 @@ KiSideEffectsBeforeWake(DISPATCHER_HEADER * hdr, case InternalSynchronizationEvent: hdr->SignalState = 0; break; - + + case InternalQueueType: case InternalSemaphoreType: hdr->SignalState--; break; @@ -348,6 +349,7 @@ BOOLEAN KeDispatcherObjectWake(DISPATCHER_HEADER* hdr) case InternalSynchronizationTimer: return(KeDispatcherObjectWakeOne(hdr)); + case InternalQueueType: case InternalSemaphoreType: DPRINT("hdr->SignalState %d\n", hdr->SignalState); if(hdr->SignalState>0) @@ -587,8 +589,18 @@ KeWaitForMultipleObjects(ULONG Count, blk->NextWaitBlock = blk + 1; } - //add wait block to disp. obj. wait list - InsertTailList(&hdr->WaitListHead, &blk->WaitListEntry); + /* + * add wait block to disp. obj. wait list + * Use FIFO for all waits except for queues which use LIFO + */ + if (WaitReason == WrQueue) + { + InsertHeadList(&hdr->WaitListHead, &blk->WaitListEntry); + } + else + { + InsertTailList(&hdr->WaitListHead, &blk->WaitListEntry); + } blk = blk->NextWaitBlock; } @@ -605,7 +617,26 @@ KeWaitForMultipleObjects(ULONG Count, &CurrentThread->WaitBlock[3].WaitListEntry); } - PsBlockThread(&Status, Alertable, WaitMode, TRUE, WaitIrql); + //io completion + if (CurrentThread->Queue) + { + CurrentThread->Queue->RunningThreads--; + if (WaitReason != WrQueue && CurrentThread->Queue->RunningThreads < CurrentThread->Queue->MaximumThreads && + !IsListEmpty(&CurrentThread->Queue->EntryListHead)) + { + KeDispatcherObjectWake(&CurrentThread->Queue->Header); + } + } + + PsBlockThread(&Status, Alertable, WaitMode, TRUE, WaitIrql, WaitReason); + + //io completion + if (CurrentThread->Queue) + { + CurrentThread->Queue->RunningThreads++; + } + + } while (Status == STATUS_KERNEL_APC);