开发者

How do you use SetThreadAffinityMask with QueryPerformanceFrequency?

I have a long standing program with the FAA that was running great until the FAA started deploying Dell GX-760 desktops. The program is a graphical replay of air traffic. I use the QueryPerformanceFrequency function to get the processor counter. With the GX 760 it appears to not be processor dependent. I found this http://msdn.microsoft.com/en-us/library/ms644904(VS.85).aspx which descibes what I am seeing.

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.

I not familiar with SetThreadAffinityMask, how does this work and how should I implement it? Here is my code that gets the count.

Thanks,

Dave

'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


Wh开发者_开发问答en 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


It isn't exactly clear what kind of problem you are having. It is very unlikely that the quoted MSDN article is relevant, a Dell Optiplex 760 doesn't have multiple processors. Just one with multiple cores, it is not subject to this kind of bug. You can easily test this by running your program with the start.exe, it allows setting the processor affinity:

start /affinity 1 yourapp.exe

Perhaps more relevant is that newer machines take shortcuts on the frequency source, using whatever source happens to be available in the chipset. They typically have a much higher return value for QueryPerformanceFrequency. Two billion isn't unusual, maybe that screws up your math. Working with 'currency' instead of a true 64-bit integer is rather toe-curling.

Also check the BIOS revision for your machine, they had rather a large number of them, all the way up to A08.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜