Solved

hardware clock

Posted on 2000-03-17
4
649 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Samsung memory install did'nt recognize by new hardware 5 31
pauing printer deamon in AIX 10 63
how to check for shares on aix 1 85
Convert OverPunch 25 65
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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.

808 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