GateWaitBlock->Thread = CurrentThread;
/* Set the Thread Wait Data */
- CurrentThread->WaitReason = WaitReason;
- CurrentThread->WaitMode = WaitMode;
CurrentThread->WaitIrql = OldIrql;
CurrentThread->GateObject = Gate;
/* Insert into the Wait List */
- InsertTailList(&Gate->Header.WaitListHead, &GateWaitBlock->WaitListEntry);
+ InsertTailList(&Gate->Header.WaitListHead,
+ &GateWaitBlock->WaitListEntry);
/* Handle Kernel Queues */
if (CurrentThread->Queue)
KiWakeQueue(CurrentThread->Queue);
}
- /* Block the Thread */
- DPRINT("Blocking the Thread: %x\n", CurrentThread);
- KiBlockThread(&Status,
- CurrentThread->Alertable,
- WaitMode,
- WaitReason);
+ /* Setup the wait information */
+ CurrentThread->WaitMode = WaitMode;
+ CurrentThread->WaitReason = WaitReason;
+ CurrentThread->WaitTime = ((PLARGE_INTEGER)&KeTickCount)->LowPart;
+ CurrentThread->State = Waiting;
+
+ /* Find a new thread to run */
+ DPRINT("Swapping threads\n");
+ Status = KiSwapThread();
/* Check if we were executing an APC */
if (Status != STATUS_KERNEL_APC) return;
/* Reschedule the Thread */
DPRINT("Unblocking the Thread\n");
KiUnblockThread(WaitThread, &WaitStatus, EVENT_INCREMENT);
- return;
quit:
/* Release the Dispatcher Database Lock */