Changeset 7362 in vbox for trunk/src/VBox/Runtime/r3/win
- Timestamp:
- Mar 7, 2008 1:34:06 PM (17 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/mp-win.cpp
r7354 r7362 1 1 /* $Id$ */ 2 2 /** @file 3 * innotek Portable Runtime - System, Win32.3 * innotek Portable Runtime - Multiprocessor, Windows. 4 4 */ 5 5 … … 31 31 #define LOG_GROUP RTLOGGROUP_SYSTEM 32 32 #include <Windows.h> 33 #include <iprt/system.h> 33 #include <iprt/mp.h> 34 #include <iprt/cpuset.h> 34 35 #include <iprt/assert.h> 35 36 36 37 38 /** @todo RTmpCpuId(). */ 37 39 38 RTDECL( unsigned) RTSystemProcessorGetCount(void)40 RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu) 39 41 { 40 SYSTEM_INFO SysInfo; 41 42 GetSystemInfo(&SysInfo); 43 44 unsigned cCpus = (unsigned)SysInfo.dwNumberOfProcessors; 45 Assert((DWORD)cCpus == SysInfo.dwNumberOfProcessors); 46 return cCpus; 42 return idCpu < MAXIMUM_PROCESSORS ? idCpu : -1; 47 43 } 48 44 49 45 50 RTDECL(uint64_t) RTSystemProcessorGetActiveMask(void) 46 RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu) 47 { 48 return (unsigned)iCpu < MAXIMUM_PROCESSORS ? iCpu : NIL_RTCPUID; 49 } 50 51 52 RTDECL(RTCPUID) RTMpGetMaxCpuId(void) 53 { 54 return MAXIMUM_PROCESSORS - 1; 55 } 56 57 58 RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu) 59 { 60 RTCPUSET Set; 61 return RTCpuSetIsMember(RTMpGetOnlineSet(&Set), idCpu); 62 } 63 64 65 RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu) 66 { 67 RTCPUSET Set; 68 return RTCpuSetIsMember(RTMpGetSet(&Set), idCpu); 69 } 70 71 72 RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet) 73 { 74 RTCPUID idCpu = RTMpGetCount(); 75 RTCpuSetEmpty(pSet); 76 while (idCpu-- > 0) 77 RTCpuSetAdd(pSet, idCpu); 78 return pSet; 79 } 80 81 82 RTDECL(RTCPUID) RTMpGetCount(void) 51 83 { 52 84 SYSTEM_INFO SysInfo; 53 54 85 GetSystemInfo(&SysInfo); 55 56 return SysInfo.dw ActiveProcessorMask;86 Assert((RTCPUID)SysInfo.dwNumberOfProcessors == SysInfo.dwNumberOfProcessors); 87 return SysInfo.dwNumberOfProcessors; 57 88 } 58 89 90 91 RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet) 92 { 93 SYSTEM_INFO SysInfo; 94 GetSystemInfo(&SysInfo); 95 return RTCpuSetFromU64(pSet, SysInfo.dwActiveProcessorMask); 96 } 97 98 99 RTDECL(RTCPUID) RTMpGetOnlineCount(void) 100 { 101 RTCPUSET Set; 102 RTMpGetOnlineSet(&Set); 103 return RTCpuSetCount(&Set); 104 } 105
Note:
See TracChangeset
for help on using the changeset viewer.