本文整理汇总了C++中RTCpuSetEmpty函数的典型用法代码示例。如果您正苦于以下问题:C++ RTCpuSetEmpty函数的具体用法?C++ RTCpuSetEmpty怎么用?C++ RTCpuSetEmpty使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTCpuSetEmpty函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RTDECL
RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
{
RTCpuSetEmpty(pSet);
int idCpu = RTMpGetCount();
while (idCpu-- > 0)
RTCpuSetAdd(pSet, idCpu);
return pSet;
}
示例2: RTDECL
RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
{
RTCPUID iCpu = RTMpGetCount();
RTCpuSetEmpty(pSet);
while (iCpu-- > 0)
RTCpuSetAddByIndex(pSet, iCpu);
return pSet;
}
示例3: RTDECL
RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
{
RTCpuSetEmpty(pSet);
RTCPUID cMax = rtMpFreeBsdMaxCpus();
for (RTCPUID idCpu = 0; idCpu < cMax; idCpu++)
if (RTMpIsCpuPossible(idCpu))
RTCpuSetAdd(pSet, idCpu);
return pSet;
}
示例4: RTDECL
RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
{
RTCpuSetEmpty(pSet);
RTCPUID cMax = rtMpLinuxMaxCpus();
for (RTCPUID idCpu = 0; idCpu < cMax; idCpu++)
if (RTMpIsCpuOnline(idCpu))
RTCpuSetAdd(pSet, idCpu);
return pSet;
}
示例5: RTDECL
RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
{
#ifdef CONFIG_SMP
RTCPUID idCpu;
RTCpuSetEmpty(pSet);
idCpu = RTMpGetMaxCpuId();
do
{
if (RTMpIsCpuOnline(idCpu))
RTCpuSetAdd(pSet, idCpu);
} while (idCpu-- > 0);
#else
RTCpuSetEmpty(pSet);
RTCpuSetAdd(pSet, RTMpCpuId());
#endif
return pSet;
}
示例6: RTDECL
RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
{
#if 0
return RTMpGetSet(pSet);
#else
RTCpuSetEmpty(pSet);
RTCPUID cMax = rtMpDarwinMaxCpus();
for (RTCPUID idCpu = 0; idCpu < cMax; idCpu++)
if (RTMpIsCpuOnline(idCpu))
RTCpuSetAdd(pSet, idCpu);
return pSet;
#endif
}
示例7: RTDECL
RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
{
RTCPUID idCpu;
RTCpuSetEmpty(pSet);
idCpu = RTMpGetMaxCpuId();
do
{
if (RTMpIsCpuOnline(idCpu))
RTCpuSetAdd(pSet, idCpu);
} while (idCpu-- > 0);
return pSet;
}
示例8: RTDECL
RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
{
RTCPUID idCpu;
RTCpuSetEmpty(pSet);
idCpu = RTMpGetMaxCpuId(); /* it's inclusive */
do
{
if (RTMpIsCpuPossible(idCpu))
RTCpuSetAdd(pSet, idCpu);
} while (idCpu-- > 0);
return pSet;
}
示例9: RTR3DECL
RTR3DECL(int) RTThreadGetAffinity(PRTCPUSET pCpuSet)
{
processorid_t iOldCpu;
int rc = processor_bind(P_LWPID, P_MYID, PBIND_QUERY, &iOldCpu);
if (rc)
return RTErrConvertFromErrno(errno);
if (iOldCpu == PBIND_NONE)
RTMpGetPresentSet(pCpuSet);
else
{
RTCpuSetEmpty(pCpuSet);
if (RTCpuSetAdd(pCpuSet, iOldCpu) != 0)
return VERR_INTERNAL_ERROR_5;
}
return VINF_SUCCESS;
}
示例10: DECLHIDDEN
DECLHIDDEN(int) rtR0MpNotificationNativeInit(void)
{
if (ASMAtomicReadBool(&g_fSolCpuWatch) == true)
return VERR_WRONG_ORDER;
/*
* Register the callback building the online cpu set as we do so.
*/
RTCpuSetEmpty(&g_rtMpSolCpuSet);
mutex_enter(&cpu_lock);
register_cpu_setup_func(rtMpNotificationCpuEvent, NULL /* pvArg */);
for (int i = 0; i < (int)RTMpGetCount(); ++i)
if (cpu_is_online(cpu[i]))
rtMpNotificationCpuEvent(CPU_ON, i, NULL /* pvArg */);
ASMAtomicWriteBool(&g_fSolCpuWatch, true);
mutex_exit(&cpu_lock);
return VINF_SUCCESS;
}
示例11: RTR3DECL
RTR3DECL(int) RTThreadGetAffinity(PRTCPUSET pCpuSet)
{
RTCpuSetEmpty(pCpuSet);
RTCpuSetAddByIndex(pCpuSet, 0);
return VINF_SUCCESS;
}
示例12: main
int main()
{
RTTEST hTest;
RTEXITCODE rcExit = RTTestInitAndCreate("tstRTMp-1", &hTest);
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
RTTestBanner(hTest);
/*
* Present and possible CPUs.
*/
RTCPUID cCpus = RTMpGetCount();
if (cCpus > 0)
RTTestIPrintf(RTTESTLVL_ALWAYS, "RTMpGetCount -> %u\n", cCpus);
else
{
RTTestIFailed("RTMpGetCount returned zero");
cCpus = 1;
}
RTCPUID cCoreCpus = RTMpGetCoreCount();
if (cCoreCpus > 0)
RTTestIPrintf(RTTESTLVL_ALWAYS, "RTMpGetCoreCount -> %d\n", (int)cCoreCpus);
else
{
RTTestIFailed("RTMpGetCoreCount returned zero");
cCoreCpus = 1;
}
RTTESTI_CHECK(cCoreCpus <= cCpus);
RTCPUSET Set;
PRTCPUSET pSet = RTMpGetSet(&Set);
RTTESTI_CHECK(pSet == &Set);
if (pSet == &Set)
{
RTTESTI_CHECK((RTCPUID)RTCpuSetCount(&Set) == cCpus);
RTTestIPrintf(RTTESTLVL_ALWAYS, "Possible CPU mask:\n");
for (int iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
{
RTCPUID idCpu = RTMpCpuIdFromSetIndex(iCpu);
if (RTCpuSetIsMemberByIndex(&Set, iCpu))
{
RTTestIPrintf(RTTESTLVL_ALWAYS, "%2d - id %d: %u/%u MHz", iCpu, (int)idCpu,
RTMpGetCurFrequency(idCpu), RTMpGetMaxFrequency(idCpu));
if (RTMpIsCpuPresent(idCpu))
RTTestIPrintf(RTTESTLVL_ALWAYS, RTMpIsCpuOnline(idCpu) ? " online\n" : " offline\n");
else
{
if (!RTMpIsCpuOnline(idCpu))
RTTestIPrintf(RTTESTLVL_ALWAYS, " absent\n");
else
{
RTTestIPrintf(RTTESTLVL_ALWAYS, " online but absent!\n");
RTTestIFailed("Cpu with index %d is report as !RTIsCpuPresent while RTIsCpuOnline returns true!\n", iCpu);
}
}
if (!RTMpIsCpuPossible(idCpu))
RTTestIFailed("Cpu with index %d is returned by RTCpuSet but not RTMpIsCpuPossible!\n", iCpu);
}
else if (RTMpIsCpuPossible(idCpu))
RTTestIFailed("Cpu with index %d is returned by RTMpIsCpuPossible but not RTCpuSet!\n", iCpu);
else if (RTMpGetCurFrequency(idCpu) != 0)
RTTestIFailed("RTMpGetCurFrequency(%d[idx=%d]) didn't return 0 as it should\n", (int)idCpu, iCpu);
else if (RTMpGetMaxFrequency(idCpu) != 0)
RTTestIFailed("RTMpGetMaxFrequency(%d[idx=%d]) didn't return 0 as it should\n", (int)idCpu, iCpu);
}
}
else
{
RTCpuSetEmpty(&Set);
RTCpuSetAdd(&Set, RTMpCpuIdFromSetIndex(0));
}
/*
* Online CPUs.
*/
RTCPUID cCpusOnline = RTMpGetOnlineCount();
if (cCpusOnline > 0)
{
if (cCpusOnline <= cCpus)
RTTestIPrintf(RTTESTLVL_ALWAYS, "RTMpGetOnlineCount -> %d\n", (int)cCpusOnline);
else
{
RTTestIFailed("RTMpGetOnlineCount -> %d, expected <= %d\n", (int)cCpusOnline, (int)cCpus);
cCpusOnline = cCpus;
}
}
else
{
RTTestIFailed("RTMpGetOnlineCount -> %d\n", (int)cCpusOnline);
cCpusOnline = 1;
}
RTCPUID cCoresOnline = RTMpGetOnlineCoreCount();
if (cCoresOnline > 0)
RTTestIPrintf(RTTESTLVL_ALWAYS, "RTMpGetOnlineCoreCount -> %d\n", (int)cCoresOnline);
else
{
RTTestIFailed("RTMpGetOnlineCoreCount -> %d, expected <= %d\n", (int)cCoresOnline, (int)cCpusOnline);
//.........这里部分代码省略.........
示例13: DECLHIDDEN
DECLHIDDEN(int) rtR0InitNative(void)
{
/*
* Init the Nt cpu set.
*/
#ifdef IPRT_TARGET_NT4
KAFFINITY ActiveProcessors = (UINT64_C(1) << KeNumberProcessors) - UINT64_C(1);
#else
KAFFINITY ActiveProcessors = KeQueryActiveProcessors();
#endif
RTCpuSetEmpty(&g_rtMpNtCpuSet);
RTCpuSetFromU64(&g_rtMpNtCpuSet, ActiveProcessors);
/** @todo Port to W2K8 with > 64 cpus/threads. */
/*
* Initialize the function pointers.
*/
#ifdef IPRT_TARGET_NT4
g_pfnrtNtExSetTimerResolution = NULL;
g_pfnrtNtKeFlushQueuedDpcs = NULL;
g_pfnrtHalRequestIpiW7Plus = NULL;
g_pfnrtHalRequestIpiPreW7 = NULL;
g_pfnrtNtHalSendSoftwareInterrupt = NULL;
g_pfnrtKeIpiGenericCall = NULL;
g_pfnrtKeInitializeAffinityEx = NULL;
g_pfnrtKeAddProcessorAffinityEx = NULL;
g_pfnrtKeGetProcessorIndexFromNumber = NULL;
g_pfnrtRtlGetVersion = NULL;
g_pfnrtKeQueryInterruptTime = NULL;
g_pfnrtKeQueryInterruptTimePrecise = NULL;
g_pfnrtKeQuerySystemTime = NULL;
g_pfnrtKeQuerySystemTimePrecise = NULL;
#else
UNICODE_STRING RoutineName;
RtlInitUnicodeString(&RoutineName, L"ExSetTimerResolution");
g_pfnrtNtExSetTimerResolution = (PFNMYEXSETTIMERRESOLUTION)MmGetSystemRoutineAddress(&RoutineName);
RtlInitUnicodeString(&RoutineName, L"KeFlushQueuedDpcs");
g_pfnrtNtKeFlushQueuedDpcs = (PFNMYKEFLUSHQUEUEDDPCS)MmGetSystemRoutineAddress(&RoutineName);
RtlInitUnicodeString(&RoutineName, L"HalRequestIpi");
g_pfnrtHalRequestIpiW7Plus = (PFNHALREQUESTIPI_W7PLUS)MmGetSystemRoutineAddress(&RoutineName);
g_pfnrtHalRequestIpiPreW7 = (PFNHALREQUESTIPI_PRE_W7)g_pfnrtHalRequestIpiW7Plus;
RtlInitUnicodeString(&RoutineName, L"HalSendSoftwareInterrupt");
g_pfnrtNtHalSendSoftwareInterrupt = (PFNHALSENDSOFTWAREINTERRUPT)MmGetSystemRoutineAddress(&RoutineName);
RtlInitUnicodeString(&RoutineName, L"KeIpiGenericCall");
g_pfnrtKeIpiGenericCall = (PFNRTKEIPIGENERICCALL)MmGetSystemRoutineAddress(&RoutineName);
RtlInitUnicodeString(&RoutineName, L"KeInitializeAffinityEx");
g_pfnrtKeInitializeAffinityEx = (PFNKEINITIALIZEAFFINITYEX)MmGetSystemRoutineAddress(&RoutineName);
RtlInitUnicodeString(&RoutineName, L"KeAddProcessorAffinityEx");
g_pfnrtKeAddProcessorAffinityEx = (PFNKEADDPROCESSORAFFINITYEX)MmGetSystemRoutineAddress(&RoutineName);
RtlInitUnicodeString(&RoutineName, L"KeGetProcessorIndexFromNumber");
g_pfnrtKeGetProcessorIndexFromNumber = (PFNKEGETPROCESSORINDEXFROMNUMBER)MmGetSystemRoutineAddress(&RoutineName);
RtlInitUnicodeString(&RoutineName, L"RtlGetVersion");
g_pfnrtRtlGetVersion = (PFNRTRTLGETVERSION)MmGetSystemRoutineAddress(&RoutineName);
# ifndef RT_ARCH_AMD64
RtlInitUnicodeString(&RoutineName, L"KeQueryInterruptTime");
g_pfnrtKeQueryInterruptTime = (PFNRTKEQUERYINTERRUPTTIME)MmGetSystemRoutineAddress(&RoutineName);
RtlInitUnicodeString(&RoutineName, L"KeQuerySystemTime");
g_pfnrtKeQuerySystemTime = (PFNRTKEQUERYSYSTEMTIME)MmGetSystemRoutineAddress(&RoutineName);
# endif
RtlInitUnicodeString(&RoutineName, L"KeQueryInterruptTimePrecise");
g_pfnrtKeQueryInterruptTimePrecise = (PFNRTKEQUERYINTERRUPTTIMEPRECISE)MmGetSystemRoutineAddress(&RoutineName);
RtlInitUnicodeString(&RoutineName, L"KeQuerySystemTimePrecise");
g_pfnrtKeQuerySystemTimePrecise = (PFNRTKEQUERYSYSTEMTIMEPRECISE)MmGetSystemRoutineAddress(&RoutineName);
#endif
/*
* HACK ALERT! (and déjà vu warning - remember win32k.sys?)
*
* Try find _KPRCB::QuantumEnd and _KPRCB::[DpcData.]DpcQueueDepth.
* For purpose of verification we use the VendorString member (12+1 chars).
*
* The offsets was initially derived by poking around with windbg
* (dt _KPRCB, !prcb ++, and such like). Systematic harvesting was then
* planned using dia2dump, grep and the symbol pack in a manner like this:
* dia2dump -type _KDPC_DATA -type _KPRCB EXE\ntkrnlmp.pdb | grep -wE "QuantumEnd|DpcData|DpcQueueDepth|VendorString"
*
* The final solution ended up using a custom harvester program called
* ntBldSymDb that recursively searches thru unpacked symbol packages for
* the desired structure offsets. The program assumes that the packages
* are unpacked into directories with the same name as the package, with
* exception of some of the w2k packages which requires a 'w2k' prefix to
* be distinguishable from another.
*/
RTNTSDBOSVER OsVerInfo;
rtR0NtGetOsVersionInfo(&OsVerInfo);
/*
* Gather consistent CPU vendor string and PRCB pointers.
*/
//.........这里部分代码省略.........
示例14: main
int main()
{
RTR3InitExeNoArguments(0);
RTPrintf("tstMp-1: TESTING...\n");
/*
* Present and possible CPUs.
*/
RTCPUID cCpus = RTMpGetCount();
if (cCpus > 0)
RTPrintf("tstMp-1: RTMpGetCount -> %d\n", (int)cCpus);
else
{
RTPrintf("tstMp-1: FAILURE: RTMpGetCount -> %d\n", (int)cCpus);
g_cErrors++;
cCpus = 1;
}
RTCPUSET Set;
PRTCPUSET pSet = RTMpGetSet(&Set);
if (pSet == &Set)
{
if ((RTCPUID)RTCpuSetCount(&Set) != cCpus)
{
RTPrintf("tstMp-1: FAILURE: RTMpGetSet returned a set with a different cpu count; %d, expected %d\n",
RTCpuSetCount(&Set), cCpus);
g_cErrors++;
}
RTPrintf("tstMp-1: Possible CPU mask:\n");
for (int iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
{
RTCPUID idCpu = RTMpCpuIdFromSetIndex(iCpu);
if (RTCpuSetIsMemberByIndex(&Set, iCpu))
{
RTPrintf("tstMp-1: %2d - id %d: %u/%u MHz", iCpu, (int)idCpu,
RTMpGetCurFrequency(idCpu), RTMpGetMaxFrequency(idCpu));
if (RTMpIsCpuPresent(idCpu))
RTPrintf(RTMpIsCpuOnline(idCpu) ? " online\n" : " offline\n");
else
{
if (!RTMpIsCpuOnline(idCpu))
RTPrintf(" absent\n");
else
{
RTPrintf(" online but absent!\n");
RTPrintf("tstMp-1: FAILURE: Cpu with index %d is report as !RTIsCpuPresent while RTIsCpuOnline returns true!\n", iCpu);
g_cErrors++;
}
}
if (!RTMpIsCpuPossible(idCpu))
{
RTPrintf("tstMp-1: FAILURE: Cpu with index %d is returned by RTCpuSet but not RTMpIsCpuPossible!\n", iCpu);
g_cErrors++;
}
}
else if (RTMpIsCpuPossible(idCpu))
{
RTPrintf("tstMp-1: FAILURE: Cpu with index %d is returned by RTMpIsCpuPossible but not RTCpuSet!\n", iCpu);
g_cErrors++;
}
else if (RTMpGetCurFrequency(idCpu) != 0)
{
RTPrintf("tstMp-1: FAILURE: RTMpGetCurFrequency(%d[idx=%d]) didn't return 0 as it should\n", (int)idCpu, iCpu);
g_cErrors++;
}
else if (RTMpGetMaxFrequency(idCpu) != 0)
{
RTPrintf("tstMp-1: FAILURE: RTMpGetMaxFrequency(%d[idx=%d]) didn't return 0 as it should\n", (int)idCpu, iCpu);
g_cErrors++;
}
}
}
else
{
RTPrintf("tstMp-1: FAILURE: RTMpGetSet -> %p, expected %p\n", pSet, &Set);
g_cErrors++;
RTCpuSetEmpty(&Set);
RTCpuSetAdd(&Set, RTMpCpuIdFromSetIndex(0));
}
/*
* Online CPUs.
*/
RTCPUID cCpusOnline = RTMpGetOnlineCount();
if (cCpusOnline > 0)
{
if (cCpusOnline <= cCpus)
RTPrintf("tstMp-1: RTMpGetOnlineCount -> %d\n", (int)cCpusOnline);
else
{
RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineCount -> %d, expected <= %d\n", (int)cCpusOnline, (int)cCpus);
g_cErrors++;
cCpusOnline = cCpus;
}
}
else
{
RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineCount -> %d\n", (int)cCpusOnline);
g_cErrors++;
cCpusOnline = 1;
//.........这里部分代码省略.........