mp-win.cpp revision 9cd42f2598c236d3c5e47f3e5bf21d4e96f001ed
5b281ba489ca18f0380d7efc7a5108b606cce449vboxsync * IPRT - Multiprocessor, Windows.
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2006-2011 Oracle Corporation
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * available from http://www.virtualbox.org. This file is free software;
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * you can redistribute it and/or modify it under the terms of the GNU
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * General Public License (GPL) as published by the Free Software
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * The contents of this file may alternatively be used under the terms
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * of the Common Development and Distribution License Version 1.0
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * VirtualBox OSE distribution, in which case the provisions of the
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * CDDL are applicable instead of those of the GPL.
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * You may elect to license modified versions of this file under the
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync * terms and conditions of either the GPL or the CDDL or both.
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync/*******************************************************************************
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync* Header Files *
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync*******************************************************************************/
c2ac210bd84591123bb8803712887e2b016cb78fvboxsyncAssertCompile(MAXIMUM_PROCESSORS <= RTCPUSET_MAX_CPUS);
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync/** @todo RTmpCpuId(). */
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync return (unsigned)iCpu < MAXIMUM_PROCESSORS ? iCpu : NIL_RTCPUID;
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync return RTCpuSetIsMember(RTMpGetOnlineSet(&Set), idCpu);
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync while (idCpu-- > 0)
04008c8439b294c40e670b4ea71471fa71ef9d69vboxsync Assert((RTCPUID)SysInfo.dwNumberOfProcessors == SysInfo.dwNumberOfProcessors);
f1958d2f336573471dde3a866c66783221ab7fdbvboxsync BOOL (WINAPI *pfnGetLogicalProcInfo)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD);
f1958d2f336573471dde3a866c66783221ab7fdbvboxsync pfnGetLogicalProcInfo = (BOOL (WINAPI *)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD))
f1958d2f336573471dde3a866c66783221ab7fdbvboxsync GetProcAddress(GetModuleHandle("KERNEL32.DLL"), "GetLogicalProcessorInformation");
9cd42f2598c236d3c5e47f3e5bf21d4e96f001edvboxsync /* 0 represents an error condition. We cannot return VERR* error codes as caller expects a
9cd42f2598c236d3c5e47f3e5bf21d4e96f001edvboxsync * unsigned value of core count.*/
9cd42f2598c236d3c5e47f3e5bf21d4e96f001edvboxsync PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pSysInfo = NULL;
9cd42f2598c236d3c5e47f3e5bf21d4e96f001edvboxsync BOOL fRc = pfnGetLogicalProcInfo(pSysInfo, &cbSysProcInfo);
9cd42f2598c236d3c5e47f3e5bf21d4e96f001edvboxsync pSysInfo = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)RTMemAlloc(cbSysProcInfo);
9cd42f2598c236d3c5e47f3e5bf21d4e96f001edvboxsync fRc = pfnGetLogicalProcInfo(pSysInfo, &cbSysProcInfo);
9cd42f2598c236d3c5e47f3e5bf21d4e96f001edvboxsync PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pSysInfoTmp = pSysInfo;
9cd42f2598c236d3c5e47f3e5bf21d4e96f001edvboxsync while (offs + sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION) <= cbSysProcInfo)
9cd42f2598c236d3c5e47f3e5bf21d4e96f001edvboxsync offs += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
1b396f7f5a76d66e62fc9d8e66dcbe8e7bf72039vboxsync/** @todo port to W2K8 / W7 w/ > 64 CPUs & grouping. */