Precision Timing? Sleep(1)=15 millisecs !!
-
Using Vis C/C++, Vis Stu 6.0 I am writing code for PCI communications. I need to loop around at 1000Hz or so to check for incoming data. Looping with Sleep(1) puts a 15.6 millisec delay, so it seems as if it uses the nefarious Tick Timer. This is way too slow for this app. Is there any way to make precision timing, or sleep with true resulution at 1 millisec or smaller? Many thanks, Robert
-
Using Vis C/C++, Vis Stu 6.0 I am writing code for PCI communications. I need to loop around at 1000Hz or so to check for incoming data. Looping with Sleep(1) puts a 15.6 millisec delay, so it seems as if it uses the nefarious Tick Timer. This is way too slow for this app. Is there any way to make precision timing, or sleep with true resulution at 1 millisec or smaller? Many thanks, Robert
Robert Palma Jr. wrote:
Is there any way to make precision timing, or sleep with true resulution at 1 millisec or smaller?
No, because Windows is not a real-time OS. See here for more.
"The largest fire starts but with the smallest spark." - David Crow
-
Using Vis C/C++, Vis Stu 6.0 I am writing code for PCI communications. I need to loop around at 1000Hz or so to check for incoming data. Looping with Sleep(1) puts a 15.6 millisec delay, so it seems as if it uses the nefarious Tick Timer. This is way too slow for this app. Is there any way to make precision timing, or sleep with true resulution at 1 millisec or smaller? Many thanks, Robert
Robert Palma Jr. wrote:
Is there any way to make precision timing, or sleep with true resulution at 1 millisec or smaller?
Sleep relinquishes the processor from the current thread for at least the time you give it. It does NOT mean that it will regain CPU time in 1 ms if you call Sleep(1); it does mean that you will not regain CPU time in less than 1 ms. You are basically telling the OS that you don't need to work for at least a certain amount of time so it can let someone else work. Windows does have a high resolution timer, but it has been a while since I even bothered with it. Check out this book. If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac