KiUpdateCpuTargetByWeight
VOID __stdcall KiUpdateCpuTargetByWeight(_KSCHEDULING_GROUP *SchedulingGroup, UINT8 ResetHistory){
UINT8 v2;
unsigned __int16 Weight;
unsigned __int16 MaxRate;
unsigned __int64 MaxQuotaCycleTarget;
unsigned __int64 v7;
__int64 v8;
char v9;
__int64 v10;
_KSCB *v11;
char v12;
_LIST_ENTRY *p_ChildList;
_KPRCB *v14;
_KSCB *Parent;
_KSCHEDULING_GROUP *v16;
unsigned __int64 v17;
__int64 v18;
unsigned int v19;
bool v20;
UINT64 v22;
UINT64 SpinCount;
v2 = ResetHistory;
Weight = SchedulingGroup->Policy.Weight;
MaxRate = SchedulingGroup->Policy.MaxRate;
if( SchedulingGroup->Parent )
{
LODWORD(v22) = 0;
v14 = KiProcessorBlock;
while( _interlockedbittestandset64((volatile signed __int32 *)v14 + 12, 0i64) )
{
do
KeYieldProcessorEx(&v22);
while( *((_QWORD *)v14 + 6) );
}
Parent = SchedulingGroup->PerProcessor[0].Parent;
v16 = SchedulingGroup->Parent;
v17 = SchedulingGroup->Policy.Weight * Parent->MinQuotaCycleTarget / v16->ChildTotalWeight;
v7 = v17;
if( Weight == MaxRate )
MaxQuotaCycleTarget = SchedulingGroup->Policy.Weight * Parent->MinQuotaCycleTarget / v16->ChildTotalWeight;
else
MaxQuotaCycleTarget = Parent->MaxQuotaCycleTarget;
_InterlockedAnd64((volatile signed __int64 *)v14 + 6, 0i64);
v2 = ResetHistory;
}
else
{
MaxQuotaCycleTarget = *(_QWORD *)KiCyclesPerGeneration;
v7 = *(_QWORD *)KiCyclesPerGeneration
* (unsigned __int64)SchedulingGroup->Policy.Weight
/ (unsigned int)KiGroupSchedulingTotalWeight;
if( Weight == MaxRate )
MaxQuotaCycleTarget = *(_QWORD *)KiCyclesPerGeneration
* (unsigned __int64)SchedulingGroup->Policy.Weight
/ (unsigned int)KiGroupSchedulingTotalWeight;
}
v19 = KeNumberProcessors_0;
v8 = 0i64;
v20 = MaxQuotaCycleTarget == *(_QWORD *)KiCyclesPerGeneration;
if( (_DWORD)KeMaximumProcessors )
{
v9 = 16 * (MaxQuotaCycleTarget == *(_QWORD *)KiCyclesPerGeneration);
do
{
v10 = (__int64)*(&KiProcessorBlock + v8);
v11 = &SchedulingGroup->PerProcessor[(unsigned int)v8];
if( v10 )
{
LODWORD(SpinCount) = 0;
while( _interlockedbittestandset64((volatile signed __int32 *)(v10 + 48), 0i64) )
{
do
KeYieldProcessorEx(&SpinCount);
while( *(_QWORD *)(v10 + 48) );
}
if( !v20 && *(_BYTE *)(v10 + 33) )
{
v18 = MaxQuotaCycleTarget * v19;
SchedulingGroup->MaxQuotaLimitCycles = v18;
SchedulingGroup->MaxQuotaCyclesRemaining = v18;
}
}
v2 = ResetHistory;
v12 = v9 | *((_BYTE *)v11 + 112) & 0xEF;
v11->MinQuotaCycleTarget = v7;
v11->MaxQuotaCycleTarget = MaxQuotaCycleTarget;
*((_BYTE *)v11 + 112) = v12;
if( v10 )
{
if( ResetHistory )
{
v11->LongTermCycles = 0i64;
v11->OverQuotaHistory = 0i64;
if( (SchedulingGroup->Policy.AllFlags & 2) != 0 )
{
KiResetScb((__int64)v11, v10);
KiCheckForEffectivePriorityChange((struct KPRCB *)v10, (INT64)v11);
}
}
_InterlockedAnd64((volatile signed __int64 *)(v10 + 48), 0i64);
}
v8 = (unsigned int)(v8 + 1);
}
while( (unsigned int)v8 < (unsigned int)KeMaximumProcessors );
}
if( v2 )
SchedulingGroup->QueryHistoryTimeStamp = KeQueryPerformanceCounter(0i64).QuadPart;
p_ChildList = &SchedulingGroup->ChildList;
if( p_ChildList->Flink != p_ChildList )
KiUpdateChildrenCpuTarget(p_ChildList, v2);
}Referenced by:
KiAssignSchedulingGroupWeights
KiUpdateChildrenCpuTarget