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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. System clock loses time and jumps back up

System clock loses time and jumps back up

Scheduled Pinned Locked Moved C / C++ / MFC
hardwarebeta-testinghelpcode-review
9 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.
  • S Offline
    S Offline
    sumeat
    wrote on last edited by
    #1

    Hi, I have an application that controls a hardware system including a camera. I have noticed (after studying the logs) that when the application is running the system clock loses time gradually over an hour and then catches up the lost time in one stroke. This causes a big jump - 2 to 3 minutes - in the log times. To futher validate my theory I ran perfmon.exe and configured it to capture CPU usage every 30 seconds. In the log generated by perfmon I notice the same jump in the time. Another interesting fact is that the interval between 2 jumps is exactly 1 hour. I have tried shutting down unnecessary services/processes to reduce the number of processes that are running but the problem still persists. I'd appreciate any feedback and/or solutions

    L D 2 Replies Last reply
    0
    • S sumeat

      Hi, I have an application that controls a hardware system including a camera. I have noticed (after studying the logs) that when the application is running the system clock loses time gradually over an hour and then catches up the lost time in one stroke. This causes a big jump - 2 to 3 minutes - in the log times. To futher validate my theory I ran perfmon.exe and configured it to capture CPU usage every 30 seconds. In the log generated by perfmon I notice the same jump in the time. Another interesting fact is that the interval between 2 jumps is exactly 1 hour. I have tried shutting down unnecessary services/processes to reduce the number of processes that are running but the problem still persists. I'd appreciate any feedback and/or solutions

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Member 519651 wrote:

      I have an application that controls a hardware system including a camera.

      Is your application blocking the interrupt system in any way, so preventing clock ticks from being seen? Does this happen when your application is not running?

      S 1 Reply Last reply
      0
      • S sumeat

        Hi, I have an application that controls a hardware system including a camera. I have noticed (after studying the logs) that when the application is running the system clock loses time gradually over an hour and then catches up the lost time in one stroke. This causes a big jump - 2 to 3 minutes - in the log times. To futher validate my theory I ran perfmon.exe and configured it to capture CPU usage every 30 seconds. In the log generated by perfmon I notice the same jump in the time. Another interesting fact is that the interval between 2 jumps is exactly 1 hour. I have tried shutting down unnecessary services/processes to reduce the number of processes that are running but the problem still persists. I'd appreciate any feedback and/or solutions

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

        Member 519651 wrote:

        ...I ran perfmon.exe and configured it to capture CPU usage every 30 seconds. In the log generated by perfmon I notice the same jump in the time.

        Which would indicate it has nothing to do with your code or this forum, correct?

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        S 1 Reply Last reply
        0
        • D David Crow

          Member 519651 wrote:

          ...I ran perfmon.exe and configured it to capture CPU usage every 30 seconds. In the log generated by perfmon I notice the same jump in the time.

          Which would indicate it has nothing to do with your code or this forum, correct?

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          S Offline
          S Offline
          sumeat
          wrote on last edited by
          #4

          It happens only when my application is running. I ran perfmon in parallel to my application to see if this is really happening and not some bug in the logger code.

          L 1 Reply Last reply
          0
          • L Lost User

            Member 519651 wrote:

            I have an application that controls a hardware system including a camera.

            Is your application blocking the interrupt system in any way, so preventing clock ticks from being seen? Does this happen when your application is not running?

            S Offline
            S Offline
            sumeat
            wrote on last edited by
            #5

            I don't handle clock interrupt in my application but may be one of the drivers (camera) does. I wrote a sample app to display the values returned by GetSystemTimeAdjustment and found that the interval and increment values are 15.625 ms and that adjustment is disabled. The MSDN help says that when time adjustment is disabled then the clock will synchrnoize using "other mechanism" and make a noticeable jump. I am guessing that the system clock is synchronizing every hour to the RTC on the motherboard. The questions I have is: 1. Why is it syncing exactly every hour? 2. What can I do to make it sync say every 10 minutes or so? I'd appreciate any thoughts/ideas on this matter.

            L 1 Reply Last reply
            0
            • S sumeat

              I don't handle clock interrupt in my application but may be one of the drivers (camera) does. I wrote a sample app to display the values returned by GetSystemTimeAdjustment and found that the interval and increment values are 15.625 ms and that adjustment is disabled. The MSDN help says that when time adjustment is disabled then the clock will synchrnoize using "other mechanism" and make a noticeable jump. I am guessing that the system clock is synchronizing every hour to the RTC on the motherboard. The questions I have is: 1. Why is it syncing exactly every hour? 2. What can I do to make it sync say every 10 minutes or so? I'd appreciate any thoughts/ideas on this matter.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Member 519651 wrote:

              1. Why is it syncing exactly every hour?

              No idea I'm afraid. I have never seen this problem, and Google does not seem to have any relevant hits. You may like to try some of the Microsoft forums to see if anyone has the answer. It may be something connected to your specific hardware configuration, in which case you need to talk to the manufacturer.

              1 Reply Last reply
              0
              • S sumeat

                It happens only when my application is running. I ran perfmon in parallel to my application to see if this is really happening and not some bug in the logger code.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Member 519651 wrote:

                It happens only when my application is running.

                Hi, Usermode applications should have no effect on the system clock. I would suspect that a device driver may be effecting the clock interrupt.In fact... what you are describing sounds somewhat normal. What you are descibing is called clock crystal drift. You should investigate the GetSystemTimeAdjustment Function[^] if you want to attempt to compensate for the clock drift. If you need a higher resolution clock... then you may need to purchase special hardware. Its as simple as that. Anyway here is what Larry Osterman had to say about it: One in a million redux[^] Best Wishes, -David Delaune

                S 1 Reply Last reply
                0
                • L Lost User

                  Member 519651 wrote:

                  It happens only when my application is running.

                  Hi, Usermode applications should have no effect on the system clock. I would suspect that a device driver may be effecting the clock interrupt.In fact... what you are describing sounds somewhat normal. What you are descibing is called clock crystal drift. You should investigate the GetSystemTimeAdjustment Function[^] if you want to attempt to compensate for the clock drift. If you need a higher resolution clock... then you may need to purchase special hardware. Its as simple as that. Anyway here is what Larry Osterman had to say about it: One in a million redux[^] Best Wishes, -David Delaune

                  S Offline
                  S Offline
                  sumeat
                  wrote on last edited by
                  #8

                  Hi, Thanks for the response. I have looked into the GetSystemTimeAdjustmemt function and when I call this function on my target system it returns 15.625 ms for interval and increment and TRUE for the disabled flag. According to help if time adjustment is disabled then the interval is added to the time at each clock interrupt and time may be synchronize using "other mechanisms". I do see a task running in the task manager that syncs the clock to RTC causing the jump in the time. I am not sure if it is timeserv.exe or not. It came and went so fast. Is there a way to change the sync interval to something else other than an hour?

                  L 1 Reply Last reply
                  0
                  • S sumeat

                    Hi, Thanks for the response. I have looked into the GetSystemTimeAdjustmemt function and when I call this function on my target system it returns 15.625 ms for interval and increment and TRUE for the disabled flag. According to help if time adjustment is disabled then the interval is added to the time at each clock interrupt and time may be synchronize using "other mechanisms". I do see a task running in the task manager that syncs the clock to RTC causing the jump in the time. I am not sure if it is timeserv.exe or not. It came and went so fast. Is there a way to change the sync interval to something else other than an hour?

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    sumeat wrote:

                    Is there a way to change the sync interval to something else other than an hour?

                    I don't really know. I would suggest that you read the documentation for your time synchronization software/service. Here are some Help and Support Articles I found. If you are using the Windows Time service they may be useful. How to synchronize the time with the Windows Time service in Windows XP[^] How to configure an authoritative time server in Windows 2000[^] Best Wishes, -David Delaune

                    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