- Invert CONFIG_SMP defines as requested by Hartmut
[reactos.git] / reactos / ntoskrnl / ke / gate.c
index 220e2f4..228ed3c 100644 (file)
@@ -19,7 +19,7 @@ VOID
 FASTCALL
 KeInitializeGate(PKGATE Gate)
 {
-    DPRINT1("KeInitializeGate(Gate %x)\n", Gate);
+    DPRINT("KeInitializeGate(Gate %x)\n", Gate);
 
     /* Initialize the Dispatcher Header */
     KeInitializeDispatcherHeader(&Gate->Header,
@@ -39,21 +39,21 @@ KeWaitForGate(PKGATE Gate,
     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;
         }
 
@@ -74,24 +74,24 @@ KeWaitForGate(PKGATE Gate,
         /* 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);
 }
 
@@ -104,7 +104,7 @@ KeSignalGateBoostPriority(PKGATE Gate)
     KIRQL OldIrql;
     NTSTATUS WaitStatus = STATUS_SUCCESS;
 
-    DPRINT1("KeSignalGateBoostPriority(EveGate %x)\n", Gate);
+    DPRINT("KeSignalGateBoostPriority(EveGate %x)\n", Gate);
 
     /* Acquire Dispatcher Database Lock */
     OldIrql = KeAcquireDispatcherDatabaseLock();
@@ -132,12 +132,12 @@ KeSignalGateBoostPriority(PKGATE Gate)
     /* 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;