mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Fix a race condition in quantum code. Spotted by Shmuel Baron.
svn path=/trunk/; revision=16904
This commit is contained in:
parent
46be8912e3
commit
34674d7646
1 changed files with 10 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue