src/gc/windows/gcenv.windows.cpp
bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_no, uint16_t* node_no)
{
    bool success = false;

    // Locate heap_number-th available processor
    uint16_t procIndex;
    size_t cnt = heap_number;
    for (uint16_t i = 0; i < GCToOSInterface::GetTotalProcessorCount(); i++)
    {
        if (g_processAffinitySet.Contains(i))
        {
            if (cnt == 0)
            {
                procIndex = i;
                success = true;
                break;
            }

            cnt--;
        }
    }

    if (success)
    {
        WORD gn, gpn;

        if (CanEnableGCCPUGroups())
        {
            GetGroupForProcessor(procIndex, &gn, &gpn);
        }
        else
        {
            gn = GroupProcNo::NoGroup;
            gpn = procIndex;
        }

        GroupProcNo groupProcNo(gn, gpn);
        *proc_no = groupProcNo.GetCombinedValue();

        PROCESSOR_NUMBER procNumber;

        if (CanEnableGCCPUGroups())
        {
            procNumber.Group = gn;
        }
        else
        {
            // Get the current processor group
            GetCurrentProcessorNumberEx(&procNumber);
        }

        if (GCToOSInterface::CanEnableGCNumaAware())
        {
            procNumber.Number   = (BYTE)gpn;
            procNumber.Reserved = 0;

            if (!GetNumaProcessorNodeEx(&procNumber, node_no))
            {
                *node_no = NUMA_NODE_UNDEFINED;
            }
        }
        else
        {   // no numa setting, each cpu group is treated as a node
            *node_no = procNumber.Group;
        }
    }

    return success;
}
// Get processor number and optionally its NUMA node number for the specified heap number
// Parameters:
//  heap_number - heap number to get the result for
//  proc_no     - set to the selected processor number
//  node_no     - set to the NUMA node of the selected processor or to NUMA_NODE_UNDEFINED
// Return:
//  true if it succeeded
Get processor number and optionally its NUMA node number for the specified heap number
Parameters:
heap_number - heap number to get the result for
proc_no     - set to the selected processor number
node_no     - set to the NUMA node of the selected processor or to NUMA_NODE_UNDEFINED
Return:
true if it succeeded
Get processor number and optionally its NUMA node number for the specified heap number Parameters : heap_number - heap number to get the result for proc_no - set to the selected processor number node_no - set to the NUMA node of the selected processor or to NUMA_NODE_UNDEFINED Return : true if it succeeded
bool GCToOSInterface::GetProcessorForHeap(uint16_t heap_number, uint16_t* proc_no, uint16_t* node_no)
{
    bool success = false;
    uint16_t procIndex;
    size_t cnt = heap_number;
    for (uint16_t i = 0; i < GCToOSInterface::GetTotalProcessorCount(); i++)
    {
        if (g_processAffinitySet.Contains(i))
        {
            if (cnt == 0)
            {
                procIndex = i;
                success = true;
                break;
            }
            cnt--;
        }
    }
    if (success)
    {
        WORD gn, gpn;
        if (CanEnableGCCPUGroups())
        {
            GetGroupForProcessor(procIndex, &gn, &gpn);
        }
        else
        {
            gn = GroupProcNo::NoGroup;
            gpn = procIndex;
        }
        GroupProcNo groupProcNo(gn, gpn);
        *proc_no = groupProcNo.GetCombinedValue();
        PROCESSOR_NUMBER procNumber;
        if (CanEnableGCCPUGroups())
        {
            procNumber.Group = gn;
        }
        else
        {
            GetCurrentProcessorNumberEx(&procNumber);
        }
        if (GCToOSInterface::CanEnableGCNumaAware())
        {
            procNumber.Number   = (BYTE)gpn;
            procNumber.Reserved = 0;
            if (!GetNumaProcessorNodeEx(&procNumber, node_no))
            {
                *node_no = NUMA_NODE_UNDEFINED;
            }
        }
        else
        {   
            *node_no = procNumber.Group;
        }
    }
    return success;
}
bool GCToOSInterface :: GetProcessorForHeap ( uint16_t heap_number , uint16_t * proc_no , uint16_t * node_no ) { bool success = false ; uint16_t procIndex ; size_t cnt = heap_number ; for ( uint16_t i = 0 ; i < GCToOSInterface :: GetTotalProcessorCount ( ) ; i ++ ) { if ( g_processAffinitySet . Contains ( i ) ) { if ( cnt == 0 ) { procIndex = i ; success = true ; break ; } cnt -- ; } } if ( success ) { WORD gn , gpn ; if ( CanEnableGCCPUGroups ( ) ) { GetGroupForProcessor ( procIndex , & gn , & gpn ) ; } else { gn = GroupProcNo :: NoGroup ; gpn = procIndex ; } GroupProcNo groupProcNo ( gn , gpn ) ; * proc_no = groupProcNo . GetCombinedValue ( ) ; PROCESSOR_NUMBER procNumber ; if ( CanEnableGCCPUGroups ( ) ) { procNumber . Group = gn ; } else { GetCurrentProcessorNumberEx ( & procNumber ) ; } if ( GCToOSInterface :: CanEnableGCNumaAware ( ) ) { procNumber . Number = ( BYTE ) gpn ; procNumber . Reserved = 0 ; if ( ! GetNumaProcessorNodeEx ( & procNumber , node_no ) ) { * node_no = NUMA_NODE_UNDEFINED ; } } else { * node_no = procNumber . Group ; } } return success ; }
Get processor number and optionally its NUMA node number for the specified heap number
Parameters:
heap_number - heap number to get the result for
proc_no     - set to the selected processor number
node_no     - set to the NUMA node of the selected processor or to NUMA_NODE_UNDEFINED
Return:
true if it succeeded
Get processor number and optionally its NUMA node number for the specified heap number Parameters : heap_number - heap number to get the result for proc_no - set to the selected processor number node_no - set to the NUMA node of the selected processor or to NUMA_NODE_UNDEFINED Return : true if it succeeded
// Locate heap_number-th available processor // Get the current processor group // no numa setting, each cpu group is treated as a node