Solved

hardware clock

Posted on 2000-03-17
4
636 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now