Fix a race condition in quantum code. Spotted by Shmuel Baron.
Modified: trunk/reactos/ntoskrnl/ke/clock.c

Modified: trunk/reactos/ntoskrnl/ke/clock.c
--- trunk/reactos/ntoskrnl/ke/clock.c	2005-07-30 19:31:52 UTC (rev 16903)
+++ trunk/reactos/ntoskrnl/ke/clock.c	2005-07-30 23:06:46 UTC (rev 16904)
@@ -305,14 +305,22 @@
 
    /* FIXME: Do DPC rate adjustments */
 
+   /* 
+    * RACE CONDITION WARNING. If one stays at DISPATCH_LEVEL for a long
+    * time the DPC routine which checks for quantum end will not be executed
+    * and decrementing the quantum here would result in overflow.
+    */
+   if (CurrentThread->Quantum < 0)
+      return;
+
    /*
     * If we're at end of quantum request software interrupt. The rest
     * is handled in KiDispatchInterrupt.
     */
    if ((CurrentThread->Quantum -= 3) <= 0)
    {
-     Prcb->QuantumEnd = TRUE;
-     HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
+      Prcb->QuantumEnd = TRUE;
+      HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
    }
 }