FASTCALL
KeInitializeGate(PKGATE Gate)
{
- DPRINT1("KeInitializeGate(Gate %x)\n", Gate);
+ DPRINT("KeInitializeGate(Gate %x)\n", Gate);
/* Initialize the Dispatcher Header */
KeInitializeDispatcherHeader(&Gate->Header,
PKWAIT_BLOCK GateWaitBlock;
NTSTATUS Status;
- DPRINT1("KeWaitForGate(Gate %x)\n", Gate);
+ DPRINT("KeWaitForGate(Gate %x)\n", Gate);
do
{
/* Lock the APC Queue */
- KeAcquireSpinLock(&CurrentThread->ApcQueueLock, &OldIrql);
-
+ OldIrql = KeAcquireDispatcherDatabaseLock();
+
/* Check if it's already signaled */
- if (!Gate->Header.SignalState)
+ if (Gate->Header.SignalState)
{
/* Unsignal it */
Gate->Header.SignalState = 0;
/* Unlock the Queue and return */
- KeReleaseSpinLock(&CurrentThread->ApcQueueLock, OldIrql);
+ KeReleaseDispatcherDatabaseLock(OldIrql);
return;
}
/* Handle Kernel Queues */
if (CurrentThread->Queue)
{
- DPRINT1("Waking Queue\n");
+ DPRINT("Waking Queue\n");
KiWakeQueue(CurrentThread->Queue);
}
- /* Unlock the Queue*/
- KeReleaseSpinLock(&CurrentThread->ApcQueueLock, OldIrql);
+ /* Setup the wait information */
+ CurrentThread->WaitMode = WaitMode;
+ CurrentThread->WaitReason = WaitReason;
+ CurrentThread->WaitTime = 0;
+ CurrentThread->State = Waiting;
- /* Block the Thread */
- DPRINT1("Blocking the Thread: %x\n", CurrentThread);
- KiBlockThread(&Status,
- CurrentThread->Alertable,
- WaitMode,
- WaitReason);
+ /* 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;
- DPRINT1("Looping Again\n");
+ DPRINT("Looping Again\n");
} while (TRUE);
}
KIRQL OldIrql;
NTSTATUS WaitStatus = STATUS_SUCCESS;
- DPRINT1("KeSignalGateBoostPriority(EveGate %x)\n", Gate);
+ DPRINT("KeSignalGateBoostPriority(EveGate %x)\n", Gate);
/* Acquire Dispatcher Database Lock */
OldIrql = KeAcquireDispatcherDatabaseLock();
/* Increment the Queue's active threads */
if (WaitThread->Queue)
{
- DPRINT1("Incrementing Queue's active threads\n");
+ DPRINT("Incrementing Queue's active threads\n");
WaitThread->Queue->CurrentCount++;
}
/* Reschedule the Thread */
- DPRINT1("Unblocking the Thread\n");
+ DPRINT("Unblocking the Thread\n");
KiUnblockThread(WaitThread, &WaitStatus, EVENT_INCREMENT);
return;