Fix a race condition in quantum code. Spotted by Shmuel Baron.

svn path=/trunk/; revision=16904
This commit is contained in:
Filip Navara 2005-07-30 23:06:46 +00:00
parent 46be8912e3
commit 34674d7646

View file

@ -305,14 +305,22 @@ KeUpdateRunTime(
/* 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);
}
}