VirtualBox

Changeset 11810 in vbox


Ignore:
Timestamp:
Aug 29, 2008 11:52:39 AM (16 years ago)
Author:
vboxsync
Message:

RTMpIsCpuOnline() for Darwin

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Performance.cpp

    r11689 r11810  
    9595int CollectorHAL::getHostCpuMHz(ULONG *mhz)
    9696{
    97 #if 1 /** @todo r=bird: this isn't taking offline cpus and gaps into account. The result may be way too low. Suggestion in the disabled #else case. */
    98     RTCPUID nProcessors = RTMpGetCount();
    99 
    100     if (nProcessors == 0)
    101         return VERR_NOT_IMPLEMENTED;
    102 
    103     uint64_t uTotalMHz  = 0;
    104 
    105     for (RTCPUID i = 0; i < nProcessors; ++i)
    106         uTotalMHz += RTMpGetCurFrequency(RTMpCpuIdFromSetIndex(i));
    107 
    108     *mhz = (ULONG)(uTotalMHz / nProcessors);
    109 
    110 #else
    11197    unsigned cCpus = 0;
    11298    uint64_t u64TotalMHz = 0;
     
    114100    RTMpGetOnlineSet(&OnlineSet);
    115101    for (RTCPUID iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
    116         Log4(("{%p} " LOG_FN_FMT ": Checking if CPU %d is member of online set...\n",
     102    {
     103        LogAleksey(("{%p} " LOG_FN_FMT ": Checking if CPU %d is member of online set...\n",
    117104                    this, __PRETTY_FUNCTION__, (int)iCpu));
    118105        if (RTCpuSetIsMemberByIndex(&OnlineSet, iCpu))
    119106        {
    120             Log4(("{%p} " LOG_FN_FMT ": Getting frequency for CPU %d...\n",
     107            LogAleksey(("{%p} " LOG_FN_FMT ": Getting frequency for CPU %d...\n",
    121108                        this, __PRETTY_FUNCTION__, (int)iCpu));
    122109            uint32_t uMHz = RTMpGetCurFrequency(RTMpCpuIdFromSetIndex(iCpu));
    123110            if (uMHz != 0)
    124111            {
    125                 Log4(("{%p} " LOG_FN_FMT ": CPU %d %u MHz\n",
     112                LogAleksey(("{%p} " LOG_FN_FMT ": CPU %d %u MHz\n",
    126113                            this, __PRETTY_FUNCTION__, (int)iCpu, uMHz));
    127114                u64TotalMHz += uMHz;
     
    129116            }
    130117        }
     118    }
    131119
    132120     AssertReturn(cCpus, VERR_NOT_IMPLEMENTED);
    133121     *mhz = (ULONG)(u64TotalMHz / cCpus);
    134 #endif
    135122
    136123    return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/r3/darwin/mp-darwin.cpp

    r11708 r11810  
    4242#include <sys/fcntl.h>
    4343#include <errno.h>
     44#include <mach/mach.h>
    4445
    4546#include <iprt/mp.h>
     
    9192RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
    9293{
    93 #if 1
     94#if 0
    9495    return RTMpIsCpuPossible(idCpu);
    9596#else
    9697    /** @todo proper ring-3 support on darwin, see #3014. */
     98    natural_t nCpus;
     99    processor_basic_info_t pinfo;
     100    mach_msg_type_number_t count;
     101    kern_return_t krc = host_processor_info(mach_host_self(),
     102        PROCESSOR_BASIC_INFO, &nCpus, (processor_info_array_t*)&pinfo, &count);
     103    AssertReturn (krc == KERN_SUCCESS, true);
     104    bool isOnline = idCpu < nCpus ? pinfo[idCpu].running : true;
     105    vm_deallocate(mach_task_self(), (vm_address_t)pinfo, count * sizeof(*pinfo));
     106    return isOnline;
    97107#endif
    98108}
     
    131141RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
    132142{
    133 #if 1
     143#if 0
    134144    return RTMpGetSet(pSet);
    135145#else
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