Newsgroups: comp.os.linux.development.apps
From: yuanhao1...@gmail.com
Date: 11 Feb 2007 19:06:10 -0800
Local: Sun, Feb 11 2007 10:06 pm
Subject: negative response time with gettimeofday
I hope someone can help me with negative time measurements I am
getting. Surely i'm doing something silly but cannot find it. code: gettimeofday (&tvStart,NULL); linStart = ((double)tvStart.tv_sec * 1000000 + 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.
| ||||||||||||||
Newsgroups: comp.os.linux.development.apps
From: "David Schwartz" <dav...@webmaster.com>
Date: 11 Feb 2007 21:33:20 -0800
Local: Mon, Feb 12 2007 12:33 am
Subject: Re: negative response time with gettimeofday
On Feb 11, 7:06 pm, yuanhao1...@gmail.com wrote:
> I hope someone can help me with negative time measurements > I am You are using the wrong function. The 'gettimeofday' function gets the > getting. > Surely i'm doing something silly but cannot find it. > code: > gettimeofday (&tvStart,NULL); system's best guess at wall time. This *can* go backwards. What you want is 'clock_gettime(CLOCK_MONOTONIC)' which measures the elaspsed time from an arbitrary reference time. (Usually the system uptime, but that's not guaranteed.) DS 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.
| ||||||||||||||
Newsgroups: comp.os.linux.development.apps
From: "Bin Chen" <binary.c...@gmail.com>
Date: 12 Feb 2007 01:35:42 -0800
Local: Mon, Feb 12 2007 4:35 am
Subject: Re: negative response time with gettimeofday
On 2月12日, 下午1时33分, "David Schwartz" <dav...@webmaster.com> wrote:
As I know, the Linux kernel read the system RTC(wall time) and then maintain the Wall time through OS timer, but why the gettimeofday not accurate? 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.
| ||||||||||||||
Newsgroups: comp.os.linux.development.apps
From: "David Schwartz" <dav...@webmaster.com>
Date: 12 Feb 2007 01:41:16 -0800
Local: Mon, Feb 12 2007 4:41 am
Subject: Re: negative response time with gettimeofday
On Feb 12, 1:35 am, "Bin Chen" <binary.c...@gmail.com> wrote:
> As I know, the Linux kernel read the system RTC(wall time) and then What makes you think it's not accurate? > maintain the Wall time through OS timer, but why the gettimeofday not > accurate? DS 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.
| ||||||||||||||
Newsgroups: comp.os.linux.development.apps
From: "Bin Chen" <binary.c...@gmail.com>
Date: 12 Feb 2007 02:02:08 -0800
Local: Mon, Feb 12 2007 5:02 am
Subject: Re: negative response time with gettimeofday
On 2月12日, 下午5时41分, "David Schwartz" <dav...@webmaster.com> wrote:
> On Feb 12, 1:35 am, "Bin Chen" <binary.c...@gmail.com> wrote: You said that it can go backwards. If it will go back of the time, is > > As I know, the Linux kernel read the system RTC(wall time) and then > What makes you think it's not accurate? it accurate. Oh, yes, it is wrong. 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.
| ||||||||||||||
Newsgroups: comp.os.linux.development.apps
From: "David Schwartz" <dav...@webmaster.com>
Date: 12 Feb 2007 03:43:47 -0800
Local: Mon, Feb 12 2007 6:43 am
Subject: Re: negative response time with gettimeofday
On Feb 12, 2:02 am, "Bin Chen" <binary.c...@gmail.com> wrote:
> > What makes you think it's not accurate? The purpose of 'gettimeofday' is to get the system's best guess at > You said that it can go backwards. If it will go back of the > time, is > it accurate. Oh, yes, it is wrong. actual wall clock time. This can go backwards. For example, suppose you check the time on a very accurate clock. It In both cases you accurately gave me your best estimate of wall clock You can ask for a time that is guaranteed monotonic or you can ask for DS 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.
| ||||||||||||||
Newsgroups: comp.os.linux.development.apps
From: "Bin Chen" <binary.c...@gmail.com>
Date: 12 Feb 2007 04:35:48 -0800
Local: Mon, Feb 12 2007 7:35 am
Subject: Re: negative response time with gettimeofday
On 2月12日, 下午7时43分, "David Schwartz" <dav...@webmaster.com> wrote:
Thanks for your explanation. > In both cases you accurately gave me your best estimate of wall clock I have some questions after I dive into the kernel source, as you > time. Nevertheless, the time went backwards. > You can ask for a time that is guaranteed monotonic or you can ask for > DS said, the kernel just estimate the time when you call the gettimeofday(). I remember this *guess* is done by accumulating each jiffy that created by OS timer. But I don't find the code that kernel read the RTC(wall time) to 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.
| ||||||||||||||
Newsgroups: comp.os.linux.development.apps
From: "David Schwartz" <dav...@webmaster.com>
Date: 12 Feb 2007 05:00:51 -0800
Local: Mon, Feb 12 2007 8:00 am
Subject: Re: negative response time with gettimeofday
On Feb 12, 4:35 am, "Bin Chen" <binary.c...@gmail.com> wrote:
> I have some questions after I dive into the kernel source, as you Correct. > said, the kernel just estimate the time when you call the > gettimeofday(). I remember this *guess* is done by accumulating each > jiffy that created by OS timer. > But I don't find the code that kernel read the RTC(wall time) to It tracks wall time itself in most hardware configurations you are > calibrate the guessed value. likely to encounter. If the TSC is usable, it will periodically work out calibration values to convert the TSC to wall time. > If all the time the kernel is guessing, If you need/want monotonic time, there are functions for that. But > there is no reason that it guess backwards. 'gettimeofday' *specifically* gives up monotonicity in exchange for a better estimate of wall time. There are plenty of reasons it guesses backwards. The kernel usually For example, suppose someone tells you the time periodically (this is Simply put, having monotonicity (never going backwards) and making the DS 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.
| ||||||||||||||
Newsgroups: comp.os.linux.development.apps
From: "Bin Chen" <binary.c...@gmail.com>
Date: 12 Feb 2007 05:52:23 -0800
Local: Mon, Feb 12 2007 8:52 am
Subject: Re: negative response time with gettimeofday
On 2月12日, 下午9时00分, "David Schwartz" <dav...@webmaster.com> wrote:
I have no idea how it works. It will calibrate the OS timer hardware so that the HZ to be generated a little faster or slower? Or it just generate a periodic timer interrupt that let kernel know a given time has passed? If the latter, which interrupt will service this? > > If all the time the kernel is guessing, I don't know why it is a *good* estimation compare to read the RTC > > there is no reason that it guess backwards. > If you need/want monotonic time, there are functions for that. But directly each time the gettimeofday is called. 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.
| ||||||||||||||
Newsgroups: comp.os.linux.development.apps
From: "David Schwartz" <dav...@webmaster.com>
Date: 12 Feb 2007 06:32:37 -0800
Local: Mon, Feb 12 2007 9:32 am
Subject: Re: negative response time with gettimeofday
On Feb 12, 5:52 am, "Bin Chen" <binary.c...@gmail.com> wrote:
> I don't know why it is a *good* estimation compare to read the RTC There are at least three reasons the RTC is not used: > directly each time the gettimeofday is called. The RTC resolution varies but is seldom better than 1/18th of a Second, the RTC is very expensive to read. It takes quite a bit of I/O Third, the RTC is notoriously inaccurate and cannot really be I believe most modern computers read the RTC only on startup. DS 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.
| ||||||||||||||
| Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy |
| ©2009 Google |