VirtualBox

Changeset 35850 in vbox


Ignore:
Timestamp:
Feb 4, 2011 1:22:30 PM (14 years ago)
Author:
vboxsync
Message:

OS X: Implement missing method for CPU capping

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp

    r35807 r35850  
    4141# include <sys/resource.h>
    4242#endif
     43#if defined(RT_OS_DARWIN)
     44# include <mach/thread_act.h>
     45# include <mach/thread_info.h>
     46# include <mach/host_info.h>
     47# include <mach/mach_init.h>
     48# include <mach/mach_host.h>
     49#endif
    4350
    4451#include <iprt/thread.h>
     
    423430    *pUserTime   = ts.ru_utime.tv_sec * 1000 + ts.ru_utime.tv_usec / 1000;
    424431    return VINF_SUCCESS;
    425 #elif !defined(RT_OS_DARWIN)
     432#elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
    426433    /* on Linux, getrusage(RUSAGE_THREAD, ...) is available since 2.6.26 */
    427434    struct timespec ts;
     
    433440    *pUserTime = (uint64_t)ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
    434441    return VINF_SUCCESS;
     442#elif defined(RT_OS_DARWIN)
     443    thread_basic_info ThreadInfo;
     444    mach_msg_type_number_t Count = sizeof(ThreadInfo) / sizeof(int);
     445    kern_return_t krc;
     446
     447    krc = thread_info(mach_thread_self(), THREAD_BASIC_INFO, (thread_info_t)&ThreadInfo, &Count);
     448    Assert(krc == KERN_SUCCESS);
     449
     450    *pKernelTime = ThreadInfo.system_time.seconds * 1000 + ThreadInfo.system_time.microseconds / 1000;
     451    *pUserTime   = ThreadInfo.user_time.seconds * 1000 + ThreadInfo.user_time.microseconds / 1000;;
     452
     453    return VINF_SUCCESS;
    435454#else
    436455    return VERR_NOT_IMPLEMENTED;
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