Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Precision Timing? Sleep(1)=15 millisecs !!

Precision Timing? Sleep(1)=15 millisecs !!

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Robert Palma Jr
    wrote on last edited by
    #1

    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

    D Z 2 Replies Last reply
    0
    • R Robert Palma Jr

      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

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • R Robert Palma Jr

        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

        Z Offline
        Z Offline
        Zac Howland
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups