Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - clock_gettime(CLOCK_REALTIME) accuracy and backend calls: (4 Items)
   
clock_gettime(CLOCK_REALTIME) accuracy and backend calls  
Hi,

I have a question about how clock_time with CLOCK_REALTIME is implemented in QNX 6.5.1.
To my knowledge in Linux 2.6.20+, it's implemented in the following way(concisely):
clock_gettime() ->
glibc -> 
---- kernel ----
sys_clock_gettime() ->
getnstimeofday() ->
__get_nsec_offset()

And __get_nsec_offset() returns a read from clock source hardware such as TSC in x86 chip.
In reality it could be more complicated, but essentially it's like this.

So, is that how QNX handles it too?

The reason I asked is because I wonder the result returned from clock_gettime() is reliable or not? Reliable in the 
sense that the nano sec value is true and we can build our application upon that.

Is there other system calls that give better timing control since QNX is a RTOS?

Thanks very much!
Re: clock_gettime(CLOCK_REALTIME) accuracy and backend calls  
clock_time() resolution is accurate to the timer tick rate - by default
1 millisecond. The only other generic mechanism is ClockCycles(). That
will (likely) have higher resolution, but there are potentially
wrap-around issues (e.g on some systems the maximum duration that
can be represented is very short (8 seconds is the lowest that I know of)).
Also, on SMP systems there's no guarantee that the ClockCycles() value
returned by one CPU has any relationship to the value returned by
another.

On Thu, May 26, 2011 at 11:16:09PM -0400, Yi Zhang wrote:
> Hi,
> 
> I have a question about how clock_time with CLOCK_REALTIME is
> implemented in QNX 6.5.1.
> To my knowledge in Linux 2.6.20+, it's implemented in the following
> way(concisely):
> clock_gettime() ->
> glibc -> 
> ---- kernel ----
> sys_clock_gettime() ->
> getnstimeofday() ->
> __get_nsec_offset()
> 
> And __get_nsec_offset() returns a read from clock source hardware such
> as TSC in x86 chip.
> In reality it could be more complicated, but essentially it's like this.
> 
> So, is that how QNX handles it too?
> 
> The reason I asked is because I wonder the result returned from
> clock_gettime() is reliable or not? Reliable in the sense that the nano
> sec value is true and we can build our application upon that.
> 
> Is there other system calls that give better timing control since QNX is
> a RTOS?
> 
> Thanks very much!
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post86184
> 

-- 
Brian Stecher (bstecher@qnx.com)        QNX Software Systems
phone: +1 (613) 591-0931 (voice)        175 Terence Matthews Cr.
       +1 (613) 591-3579 (fax)          Kanata, Ontario, Canada K2M 1W8
Re: clock_gettime(CLOCK_REALTIME) accuracy and backend calls  
Brian,

Thanks for this explanation. Is there any API to obtain high resolution timestamps like QueryPerformanceCounter on 
Windows, that works reliably with SMP?  Or do people just use some platform specific hardware timers?

Regards,-
 s.
Re: clock_gettime(CLOCK_REALTIME) accuracy and backend calls  
People just use platform specific timers.

On Tue, May 31, 2011 at 07:15:54PM -0400, Saul A wrote:
> Brian,
> 
> Thanks for this explanation. Is there any API to obtain high resolution
> timestamps like QueryPerformanceCounter on Windows, that works reliably
> with SMP?  Or do people just use some platform specific hardware timers?
> 
> Regards,-
>  s.
> 
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post86306
> 

-- 
Brian Stecher (bstecher@qnx.com)        QNX Software Systems
phone: +1 (613) 591-0931 (voice)        175 Terence Matthews Cr.
       +1 (613) 591-3579 (fax)          Kanata, Ontario, Canada K2M 1W8