gettimeofday()
is hardware dependent with RTC.
Can some one suggest how we can avoid the use of the same in Application Programming. How we can approach the use of System ticks ?
thanks in advance !
gettimeofday()
is hardware dependent with RTC.
Can some one suggest how we can avoid the use of the same in Application Programming. How we can approach the use of System ticks ?
thanks in advance !
To get time in ticks you might like to use times()
.
However is is not clear whether those ticks are measured from boot-time.
RETURN VALUE
times() returns the number of clock ticks that have elapsed since an arbitrary point in the past. [...]
[...]
NOTES
On Linux, the "arbitrary point in the past" from which the return value of times() is measured has varied across kernel versions. On Linux 2.4 and earlier this point is the moment the system was booted. Since Linux 2.6, this point is (2^32/HZ) - 300 (i.e., about 429 million) seconds before system boot time. This variability across kernel versions (and across UNIX implementations), combined with the fact that the returned value may overflow the range of clock_t, means that a portable application would be wise to avoid using this value. To measure changes in elapsed time, use clock_gettime(2) instead.
Reading this using clock_gettitme()
with the CLOCK_BOOTTIME
timer might be the more secure and more portable way to go. If this function and/or timer is available for system without RTC I'm not sure. Others are encouraged to clarfiy this.