VirtualBox

Changeset 2981 in kBuild


Ignore:
Timestamp:
Oct 12, 2016 11:12:58 AM (8 years ago)
Author:
bird
Message:

kmk: Use GetActiveProcessorCount instead of GetSystemInfo when possible. Good for systems with lots of CPUs. However, limit it to 64 so we don't run into trouble with child waiting in subproc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/main.c

    r2931 r2981  
    12391239# ifdef WINDOWS32
    12401240    /* Windows: Count the active CPUs. */
    1241     int cpus, i;
    1242     SYSTEM_INFO si;
    1243     GetSystemInfo(&si);
    1244     for (i = cpus = 0; i < sizeof(si.dwActiveProcessorMask) * 8; i++)
     1241    int cpus;
     1242
     1243    /* Process groups (W7+). */
     1244    typedef DWORD (WINAPI *PFNGETACTIVEPROCESSORCOUNT)(DWORD);
     1245    PFNGETACTIVEPROCESSORCOUNT pfnGetActiveProcessorCount;
     1246    pfnGetActiveProcessorCount = (PFNGETACTIVEPROCESSORCOUNT)GetProcAddress(GetModuleHandleW(L"kernel32.dll"),
     1247                                                                            "GetActiveProcessorCount");
     1248    if (pfnGetActiveProcessorCount)
     1249      cpus = pfnGetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
     1250    /* Legacy (<= Vista). */
     1251    else
    12451252      {
    1246         if (si.dwActiveProcessorMask & 1)
    1247           cpus++;
    1248         si.dwActiveProcessorMask >>= 1;
     1253        int i;
     1254        SYSTEM_INFO si;
     1255        GetSystemInfo(&si);
     1256        for (i = cpus = 0; i < sizeof(si.dwActiveProcessorMask) * 8; i++)
     1257          {
     1258            if (si.dwActiveProcessorMask & 1)
     1259              cpus++;
     1260            si.dwActiveProcessorMask >>= 1;
     1261          }
    12491262      }
    1250     return cpus ? cpus : 1;
     1263    if (!cpus)
     1264      cpus = 1;
     1265    if (cpus > 64)
     1266      cpus = 64; /* (wait for multiple objects limit) */
     1267    return cpus;
    12511268
    12521269# elif defined(__OS2__)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette