gpt4 book ai didi

windows - 如何将 SetThreadAffinityMask 与 QueryPerformanceFrequency 一起使用?

转载 作者:可可西里 更新时间:2023-11-01 12:07:24 26 4
gpt4 key购买 nike

我与 FAA 有一个长期计划,在 FAA 开始部署 Dell GX-760 台式机之前一直运行良好。该程序是空中交通的图形重播。我使用 QueryPerformanceFrequency 函数来获取处理器计数器。对于 GX 760,它似乎不依赖于处理器。我找到了这个 http://msdn.microsoft.com/en-us/library/ms644904(VS.85).aspx它描述了我所看到的。

On a multiprocessor computer, it should not matter which processor is called. However, youit can get different results on different processors due to bugs in the basic input/output system (BIOS) or the hardware abstraction layer (HAL). To specify processor affinity for a thread, use the SetThreadAffinityMask function.

我不熟悉 SetThreadAffinityMask,它是如何工作的,我应该如何实现它?这是我获取计数的代码。

谢谢,

戴夫

'Declarations
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long

'I set the Frequency on Startup
cTime.SetFrequency

Public Sub SetFrequency()
'Get the Processor Frequency. This is locked at Windows startup and does n
Dim f As Currency
QueryPerformanceFrequency f
cTime.Frequency = f

End Sub


When the program needs the time it calls

Public Function CurrentCount() As Currency
'What is the current processoer count
QueryPerformanceCounter CurrentCount 'get current count number
End Function

最佳答案

目前还不清楚您遇到的是哪种问题。引用的 MSDN 文章非常不太可能相关,Dell Optiplex 760 没有多个处理器。只是一个多核的,不会有这种bug的。您可以通过使用 start.exe 运行您的程序来轻松地对此进行测试,它允许设置处理器亲和性:

start /affinity 1 yourapp.exe

也许更相关的是,较新的机器在频率源上采用了捷径,使用芯片组中恰好可用的任何源。它们的 QueryPerformanceFrequency 返回值通常。二十亿并不稀奇,也许这会把你的数学搞砸。使用“货币”而不是真正的 64 位整数是相当令人费解的。

还要检查你机器的 BIOS 版本,他们有相当多的版本,一直到 A08。

关于windows - 如何将 SetThreadAffinityMask 与 QueryPerformanceFrequency 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4237872/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com