CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    Join Date
    Nov 2002
    Location
    Foggy California
    Posts
    1,245
    So are the two programs then going to run on different computers? Is that part of your requirement that one will run on Windows and the other *nix?

  2. #17
    Join Date
    Jan 2004
    Posts
    20
    Originally posted by CornedBee
    Actually clock()'s unit is 1/CLOCKS_PER_SEC.
    1/1000th of a second on Windows, and I doubt how accurate this actually is.

    You can use time(time_t*), it has second resolution. But that's probably too inaccurate.

    For high numbers, but with great accuracy, you can use QueryPerformanceCounter, only available in Windows.
    well, outside of the windows world it appears that CLOCKS_PER_SEC=1000000L, so the counter overflows in little more than one hour. and no, there's nothing (portable) you can do about it.

  3. #18
    Join Date
    Nov 2002
    Location
    Foggy California
    Posts
    1,245
    Ok, you did say that you wanted to synchronize two different computers! (sorry I didn't see that before). I happen to work with embeded systems at my job and am familliar with this area. I strongly recommend that you do NOT rely on timers. Even if the computers you have have good oscillators, there will still be a little bit of drift between the different clocks. (BTW, clock() is a very bad method to use for other reasons -- it measures the amount of time spent in the current process, not the difference of between two times). The only way to synchronize correctly is to have one computer send a signal to the second computer -- perhaps through a TCP/IP port. Anyway, good luck!

    - Kevin

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured