Solved

hardware clock

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
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.

762 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

20 Experts available now in Live!

Get 1:1 Help Now