Solved

hardware clock

Posted on 2000-03-17
4
660 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix/bash: scripted arithmetic 13 103
mobaxterm not able to change directory 28 373
insert flat files in to tables based upon first character 1 61
sed command 3 28
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 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…
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.
Suggested Courses

734 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