Solved

hardware clock

Posted on 2000-03-17
4
655 Views
Last Modified: 2013-12-27
How can I get the hardwarr clock in my c++ program beneath Solaris 2.5.1/2.6? Is there any API? What is the difference between clock_settime(), gettimeofday() and time()? How precicious are them? I want to get to it because I would take it as the time base in my system.Thank you!
0
Comment
Question by:peak_chen
  • 2
4 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 2630421
Why would you want to get to the hardware clock?
0
 

Author Comment

by:peak_chen
ID: 2630824
Edited text of question.
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2631426
I guess I didn't make my query very clear. Why the hardware clock as opposed to gettimeofday(). If the sytem is set up to time sync via NTP (Network Time Protocol), I believe that the system call is usually more accurate as the hardware clock isn't necessarily updated as often. And I'd have to check to be certain, but I think the hardware clock only has a resolution of 1 sec. The system clock does a bit better as it counts clock ticks.
0
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 15 total points
ID: 2637947
The hardware clock on most modern SPARC systems counts clock ticks since system bootup in (I think) miliseconds.  This isn't very useful and you can only access it from inside the kernel.

clock_settime() and clock_gettime() are the low level timer routines that wrap the hardware clock in a nice API for handling multiple timers, and converting everything to nanoseconds.  This is the closest you can get to the hardware clock under Solaris.

gettimeofday() is similar to cloc_gettime(CLOCK_REALTIME, ), but with maximum resolution of microseconds (not much of an issue in Solaris, where the hardware clock isn't more accurate than this and there's system call overhead, etc. that skews things even more).

time() is similar to gettimeofday(), but with maximum resolution of one second.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question