Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Getting "absolute time" in Linux
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Boris Benenson  
View profile  
 More options Nov 15 2006, 6:30 am
Newsgroups: comp.os.linux.development.system
From: Boris Benenson <boris.benen...@marconi.com>
Date: Tue, 14 Nov 2006 14:30:57 -0500
Local: Wed, Nov 15 2006 6:30 am
Subject: Getting "absolute time" in Linux
Is there a way in either standard or Real-time Linux to get "absolute
number of ticks (or seconds) since the Epoc (or some other configurable
starting point), regardless of the kernel clock resets via
settimeofday() and the RTC resets via hwclock set and regardless of the
system reboots?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
malc  
View profile  
 More options Nov 15 2006, 10:42 am
Newsgroups: comp.os.linux.development.system
From: malc <m...@pulsesoft.com>
Date: Tue, 14 Nov 2006 23:42:09 +0000 (UTC)
Local: Wed, Nov 15 2006 10:42 am
Subject: Re: Getting "absolute time" in Linux

Boris Benenson <boris.benen...@marconi.com> writes:
> Is there a way in either standard or Real-time Linux to get "absolute
> number of ticks (or seconds) since the Epoc (or some other
> configurable starting point), regardless of the kernel clock resets
> via settimeofday() and the RTC resets via hwclock set and regardless
> of the system reboots?

http://www.opengroup.org/onlinepubs/000095399/functions/clock_gettime...
CLOCK_MONOTONIC

`man clock_gettime' on this Linux box says:

AVAILABILITY
       On  POSIX  systems on which these functions are available,
       the symbol _POSIX_TIMERS is defined  in  <unistd.h>  to  a
       value greater than 0.  The symbols _POSIX_MONOTONIC_CLOCK,
       _POSIX_CPUTIME,   _POSIX_THREAD_CPUTIME   indicate    that
       CLOCK_MONOTONIC,                 CLOCK_PROCESS_CPUTIME_ID,
       CLOCK_THREAD_CPUTIME_ID   are   available.    (See    also
       sysconf(3).)

Availablility of CLOCK_MONOTONIC is system (and not just libc)
specific (for instance stock Linux 2.4 kernels do not have it,
2.6 do)

--
vale


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Hauck  
View profile  
 More options Nov 15 2006, 10:16 am
Newsgroups: comp.os.linux.development.system
From: Bob Hauck <postmas...@localhost.localdomain>
Date: Tue, 14 Nov 2006 18:16:05 -0500
Local: Wed, Nov 15 2006 10:16 am
Subject: Re: Getting "absolute time" in Linux
On Tue, 14 Nov 2006 14:30:57 -0500, Boris Benenson

<boris.benen...@marconi.com> wrote:
> Is there a way in either standard or Real-time Linux to get "absolute
> number of ticks (or seconds) since the Epoc (or some other
> configurable starting point), regardless of the kernel clock resets
> via settimeofday() and the RTC resets via hwclock set and regardless
> of the system reboots?

clock_gettime (CLOCK_MONOTONIC, tp):

That will get a guaranteed-monotonic time regardless of settimeofday()
and friends.  In Linux it is the time since the last boot, but POSIX
doesn't guarantee that, just that it is monotonically increasing.  But
if what you want is a clock to use to trigger an event X seconds from
now, that's the one you want.

I don't know of a way to get the absolute time that will work across a
reboot or reset of the RTC.  That last seems like kind of a tall order
since it is the only thing in the system that keeps time when the power
is off.

NTP might do some of what you want, but if the goal is to have the time
be correct even if root tries to mess it up, then NTP won't help.

--
 -| Bob Hauck
 -| Have you had enough of George Bush yet?
 -| http://www.haucks.org/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google