Click here to Skip to main content
15,879,095 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How Can I set Noise In Image ? Pin
Marco Bertschi14-Mar-13 22:21
protectorMarco Bertschi14-Mar-13 22:21 
AnswerRe: How Can I set Noise In Image ? Pin
nv316-Mar-13 2:16
nv316-Mar-13 2:16 
QuestiontimeGetTime() is unreliable on my computer too, not monotonic! Pin
Robert Inventor14-Mar-13 18:04
Robert Inventor14-Mar-13 18:04 
AnswerMessage Closed Pin
14-Mar-13 18:15
Robert Inventor14-Mar-13 18:15 
GeneralMessage Closed Pin
14-Mar-13 18:20
Robert Inventor14-Mar-13 18:20 
GeneralMessage Closed Pin
14-Mar-13 18:53
Robert Inventor14-Mar-13 18:53 
GeneralMessage Closed Pin
14-Mar-13 19:19
Robert Inventor14-Mar-13 19:19 
AnswerRe: timeGetTime() is unreliable on my computer too, not monotonic! Pin
Robert Inventor19-Mar-13 7:31
Robert Inventor19-Mar-13 7:31 
This is now solved.

First - it was a core switching issue. The code to confine to a single core has to be called in advance - I think possibly the thread has to sleep first before the system can assign it to a new core, at any rate doesn't work to just set it immediately before every time check and release it again afterwards. Also there was a bug in my code when checking to see if hte time was going backwards forgot to check if the previous time was recorded for the same thread, the dTimeWas should have been a thread local variable.

But - even after fixing all that, and tied to a single core, the timing was still inaccurate. It was monotonic but inaccurately timed, the reported time in ms sometimes passed more quickly than real time and sometimes passed more slowly.

I could check this by doing a real time recording to audio of the notes played by my app - which according to the high performance counter were played at equally spaced 100 ms intervals - but when you looked at the recording the actual recorded times were offset sometimes as much as 30 ms from the previously recorded note - had one recording that recorded an 80 ms note followed by a 110 ms note when the high precision timer said that they were all exactly 100 ms to within sub millisecond precision.

Finally fixed it by looking up the interrupt timer which is available to every user mode process as a volatile area of shared memory in a structure called KUSER_SHARED_DATA in the same location in the address space in every process.

This timer is highly accurate, not just sub-millisecond, it is also well sub-microsecond on my laptop anyway. It also records the time correctly. And there is almost no overhead involved in looking it up as it is only a memory look up, just like accessing any other area of memory.

Details here:

QueryPerformanceCounter-inaccurate-timing - SOLVED[^]
QuestionQueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor14-Mar-13 15:50
Robert Inventor14-Mar-13 15:50 
AnswerRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor14-Mar-13 18:07
Robert Inventor14-Mar-13 18:07 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex15-Mar-13 0:24
dusty_dex15-Mar-13 0:24 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor18-Mar-13 14:44
Robert Inventor18-Mar-13 14:44 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex18-Mar-13 22:08
dusty_dex18-Mar-13 22:08 
AnswerRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor19-Mar-13 6:19
Robert Inventor19-Mar-13 6:19 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex19-Mar-13 8:34
dusty_dex19-Mar-13 8:34 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor20-Mar-13 10:10
Robert Inventor20-Mar-13 10:10 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor20-Mar-13 11:12
Robert Inventor20-Mar-13 11:12 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex20-Mar-13 11:18
dusty_dex20-Mar-13 11:18 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor20-Mar-13 12:15
Robert Inventor20-Mar-13 12:15 
QuestionHelp in Win32 programming with c++ Pin
naseer86114-Mar-13 8:44
naseer86114-Mar-13 8:44 
AnswerRe: Help in Win32 programming with c++ Pin
NotPolitcallyCorrect14-Mar-13 8:50
NotPolitcallyCorrect14-Mar-13 8:50 
GeneralRe: Help in Win32 programming with c++ Pin
naseer86118-Mar-13 9:41
naseer86118-Mar-13 9:41 
AnswerRe: Help in Win32 programming with c++ Pin
Maximilien14-Mar-13 8:54
Maximilien14-Mar-13 8:54 
AnswerRe: Help in Win32 programming with c++ Pin
Captain Price16-Mar-13 2:55
professionalCaptain Price16-Mar-13 2:55 
QuestionNeed a free image library, png, Visual Studio 6.0 Pin
Andrlage14-Mar-13 5:52
Andrlage14-Mar-13 5:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.