KiAssignSchedulingGroupWeights

VOID __stdcall KiAssignSchedulingGroupWeights(
        _KSCHEDULING_GROUP_TYPE Type,
        UINT8 ResetHistory,
        _KSCHEDULING_GROUP *Parent){
  unsigned int ChildMinRate; 
  _LIST_ENTRY *Flink; 
  _LIST_ENTRY *p_ChildList; 
  _KSCHEDULING_GROUP *p_Blink; 

  if( Type )
  {
    if( Parent )
      ChildMinRate = Parent->ChildMinRate;
    else
      ChildMinRate = KiGroupSchedulingMinimumRate;
  }
  else if( Parent )
  {
    if( !Parent->ChildTotalWeight )
      return;
    ChildMinRate = Parent->ChildMinWeight;
  }
  else
  {
    if( !KiGroupSchedulingTotalWeight )
      return;
    ChildMinRate = KiGroupSchedulingMinimumWeight;
  }
  if( Parent )
  {
    p_ChildList = &Parent->ChildList;
    Flink = Parent->ChildList.Flink;
  }
  else
  {
    Flink = (_LIST_ENTRY *)KiSchedulingGroupList;
    p_ChildList = (_LIST_ENTRY *)&KiSchedulingGroupList;
  }
  do
  {
    p_Blink = (_KSCHEDULING_GROUP *)&Flink[-4].Blink;
    if( (HIDWORD(Flink[-4].Blink) & 1) == Type )
    {
      p_Blink->RelativeWeight = (p_Blink->Policy.Weight << 7) / ChildMinRate;
      if( Type == WeightBased )
        KiUpdateCpuTargetByWeight(p_Blink, ResetHistory, (_KPRCB *)Parent);
    }
    Flink = Flink->Flink;
  }
  while( Flink != p_ChildList );
}

Referenced by:

KeInsertSchedulingGroup
KeRemoveSchedulingGroup
KeSetSchedulingGroupCpuRates
KeSetSchedulingGroupWeights
KeUpdateGroupSchedulingConstants