NTP and clocks under QNX

I have been playing around with an early version of NTP that was ported
to QNX4. I’ve been adding functions like ClockAdjust() and ClockCycles()
to the program. Its working fairly well but it brings up some questions
how QNXRTP 6.1 handles the clock.

ClockAdjust() appears to be an offset that is applied to any request for an
absolute time. It appears to be stored in
It also implies that the hardware clock is not being adjusted and that it is
resolution limited to hardware clock steps. Does this mean that if I set up
periodic timer using relative times it would become out of sync with the
time that is being corrected using ClockAdjust() ? Thus requiring one to use
series of absolute times.

NTP is limited in resolution to about +/- 1/2 the OS tick on most systems
and it
appears to be about what I am getting. But the ClockCycles() feature on the
CPUs opens up the possibility of doing much better. Presently I am
attempting to
sync to the tick using delay(1) and reading the time using gettimeofday()
followed by
a call to ClockCycles(). This seems to work in that I don’t get 1 ms steps
in my
time comparisons. But I am getting some drifts of about +/- 1 ms over a half
This is maybe/(probably) a problem with the code that I don’t have quite
right yet.
It would make it a lot easier though if QNX stored the ClockCycles() reading
the ISR for the timer tick. Then one could read the absolute time at any
point to
a resolution of sub-microseconds ! :slight_smile: Of course my application doesn’t
require this
resolution. I just wanted to sync the clocks to within tens of ms and RTP
ship with a version of NTP. Plus this looked like a good application to test
QNX. BTW, is delay(1) a good/(recommended) way to sync an application to the
tick ?

I was inspecting other variables in the syspage space in hope of finding
stored in there. I understand most of the values but
It seems to be always changing. I assumed it would be the absolute system
without the ClockAdjust() correction applied. But this value should only be
every tick. What is it ?


Dave Eisert