System clock loses time and jumps back up
-
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
-
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
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?
-
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
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
-
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
-
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?
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.
-
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.
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.
-
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.
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
-
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
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?
-
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?
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