[ros-diffs] [navaraf] 16904: Fix a race condition in quantum code.
Spotted by Shmuel Baron.
navaraf at svn.reactos.com
navaraf at svn.reactos.com
Sun Jul 31 01:06:50 CEST 2005
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);
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-diffs/attachments/20050731/04ca794f/attachment.html
More information about the Ros-diffs
mailing list