VirtualBox

source: vbox/trunk/src/VBox/Runtime/r3/win/mp-win.cpp@ 13299

Last change on this file since 13299 was 9429, checked in by vboxsync, 17 years ago

RTMpDoesCpuExist -> RTMpIsCpuPossible. Changed the RTMpGetCount and RTMpGetSet specification to include all possible cpus.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1/* $Id: mp-win.cpp 9429 2008-06-05 15:22:37Z vboxsync $ */
2/** @file
3 * IPRT - Multiprocessor, Windows.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#define LOG_GROUP RTLOGGROUP_SYSTEM
36#include <Windows.h>
37#include <iprt/mp.h>
38#include <iprt/cpuset.h>
39#include <iprt/assert.h>
40
41
42/** @todo RTmpCpuId(). */
43
44RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
45{
46 return idCpu < MAXIMUM_PROCESSORS ? idCpu : -1;
47}
48
49
50RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
51{
52 return (unsigned)iCpu < MAXIMUM_PROCESSORS ? iCpu : NIL_RTCPUID;
53}
54
55
56RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
57{
58 return MAXIMUM_PROCESSORS - 1;
59}
60
61
62RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
63{
64 RTCPUSET Set;
65 return RTCpuSetIsMember(RTMpGetOnlineSet(&Set), idCpu);
66}
67
68
69RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
70{
71 RTCPUSET Set;
72 return RTCpuSetIsMember(RTMpGetSet(&Set), idCpu);
73}
74
75
76RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
77{
78 RTCPUID idCpu = RTMpGetCount();
79 RTCpuSetEmpty(pSet);
80 while (idCpu-- > 0)
81 RTCpuSetAdd(pSet, idCpu);
82 return pSet;
83}
84
85
86RTDECL(RTCPUID) RTMpGetCount(void)
87{
88 SYSTEM_INFO SysInfo;
89 GetSystemInfo(&SysInfo);
90 Assert((RTCPUID)SysInfo.dwNumberOfProcessors == SysInfo.dwNumberOfProcessors);
91 return SysInfo.dwNumberOfProcessors;
92}
93
94
95RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
96{
97 SYSTEM_INFO SysInfo;
98 GetSystemInfo(&SysInfo);
99 return RTCpuSetFromU64(pSet, SysInfo.dwActiveProcessorMask);
100}
101
102
103RTDECL(RTCPUID) RTMpGetOnlineCount(void)
104{
105 RTCPUSET Set;
106 RTMpGetOnlineSet(&Set);
107 return RTCpuSetCount(&Set);
108}
109
Note: See TracBrowser for help on using the repository browser.

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