OS clock sync up with Real time clock, at Boot up

I’m using QNX6.2.0. At boot-up i’m observing, that my OS clock is lagging from the RT clock by a few seconds. later if i run “rtc hw” and read the OS clock value, there is no error in the OS clock.

This behavior is observed consistently at Low temperatures, temperatures below 20 degree C. if i switch Off the system for 20mins or more and power ON, i get this issue.
If the temperature is more, say around 25, then issue is observed around 30mins, switch Off time.

Questions:

  1. Is the IPL responsible for the initial sync up?, i’m not doing any RTC sync up in my boot script.
  2. Can anyone help me in this regard?

Very interesting to say the least. I’ve never heard of this type of problem before. Let me point out two possible areas you might want to look at.

  1. The only way I know of that the RT clock time gets to the OS time is via the rtc command. At startup it is remotely possible that between the time that rtc reads the RT clock and updates the OS clock that there is a delay. For example, if you were runnings drivers such as a disk driver that could become very cpu intensive for brief periods, combined with careful timing, such an event could occur. I find this rather unlikely and it doesn’t explain the temperature phenomenon. It would be easy to rule this out. Just put in a delay at the end of the rc.local script followed by the rtc command and see if the problem goes away.

  2. The temperature problem suggests another possibility. A marginally defective crystal that runs slow while cold might be possible. To rule this out, you might need a duplicate system to compare it with. It might even be possible that this is common behavior, but rarely noticed.

A more important question might be, what do you want to do about the problem? If being off a few seconds is a problem, even without this weird phenomenon, then you need to look at other ways to solve this. Most cpu’s can only keep the time accurate within a few seconds a day. To deal with this, you might want to periodically refresh the time with rtc, maybe once an hour. But the RT clock itself will have inaccuracies of a few seconds over a period of a month. If that is a problem, you need to look at syncing to a more accurate standard. If you are networked attached, you should look into ntp.