Like Tree2Likes

Minute Delay Loop

This is a discussion on Minute Delay Loop within the C++ Programming forums, part of the General Programming Boards category; I'm not on a network and I have auto-sync turned off. "difference between current time and desired time" Based on ...

  1. #31
    Registered User
    Join Date
    Feb 2010
    Posts
    93
    I'm not on a network and I have auto-sync turned off.

    "difference between current time and desired time"
    Based on what? As in, what do I reference to do the math if the time is the time and yet the time is the problem?

    Thanks for helping but I think this will go down as hack time, meaning time to do some ugly code with stupid comments.
    Anyway, thanks again.

  2. #32
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    Code:
    while (current_time < desired_time)
    {
         sleep(desired_time - current_time);
    }
    Desired_time could be, for example, 7:04:00. In your case, on the minute time goes backwards, it will first sleep 60 seconds, check, realize now there's 3 seconds left, and sleep 3 more seconds, before returning.

  3. #33
    Registered User
    Join Date
    Feb 2010
    Posts
    93
    It happens that I was already doing that here:
    Minute Delay Loop
    And surprisingly, it does work to give me 00 every time (although I'm still suspicious it's too KISS).

    After more Googling, I'm not the only one:
    NTP 4.2.6p4 Released - comp.protocols.time.ntp | Google Groups

    It's good as it's going to get without buying a new computer (evidentally).

  4. #34
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    Hmm if your system is really losing 2 seconds every 10 minutes, that would be 12 seconds per hour, or about 5 minutes a day. I'm sure that would be noticeable?

  5. #35
    Registered User
    Join Date
    Feb 2010
    Posts
    93
    I found something interesting => GetSystemTimeAdjustment:
    GetSystemTimeAdjustment function

    My computer is TRUE.

    It says (quote):
    A value of TRUE indicates that periodic time adjustment is disabled, and the system time-of-day clock advances at the normal rate. In this mode, the system may adjust the time of day using its own internal time synchronization mechanisms. These internal time synchronization mechanisms may cause the time-of-day clock to change during the normal course of the system operation, which can include noticeable jumps in time as deemed necessary by the system.

    Bingo.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Wait just a minute here!!!
    By Kennedy in forum C Programming
    Replies: 7
    Last Post: 04-13-2009, 10:36 AM
  2. While Loop and Delay
    By hmd in forum C Programming
    Replies: 5
    Last Post: 02-25-2008, 01:34 PM
  3. Minute to hour/minute conversion program
    By Remius in forum C Programming
    Replies: 7
    Last Post: 12-29-2007, 08:39 AM
  4. 12 minute timer
    By Gone in forum C++ Programming
    Replies: 2
    Last Post: 12-31-2003, 04:30 PM
  5. Delay A While Loop
    By SonicWave in forum C++ Programming
    Replies: 4
    Last Post: 09-09-2001, 11:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21