Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Oct 2005 13:24:30 -0400
From:      Chuck Swiger <cswiger@mac.com>
To:        Robert Watson <rwatson@FreeBSD.org>
Cc:        Poul-Henning Kamp <phk@phk.freebsd.dk>, David Xu <davidxu@freebsd.org>, current@freebsd.org
Subject:   Re: Timers and timing, was: MySQL Performance 6.0rc1
Message-ID:  <43625ECE.7010804@mac.com>
In-Reply-To: <20051028144307.X53858@fledge.watson.org>
References:  <32412.1130505646@critter.freebsd.dk> <436229CF.6040001@freebsd.org> <20051028144307.X53858@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Robert Watson wrote:
> On Fri, 28 Oct 2005, David Xu wrote:
>> Poul-Henning Kamp wrote:
>>>> On the other hand, a lower risk change might be to simply add a new 
>>>> CLOCK_ type for lower resolution, and have a timer synchronize a 
>>>> variable to the system clock once every 1/10 of a second.  This 
>>>> avoids having to muck with VM layout, etc.
>>>
>>> Is the CLOCK_* namespace ours to muck about with in the first place?
>>>
>> I prefer this way, can you implement it? The global page idea is a 
>> complex, someone can slowly work on it, there are many things can be 
>> done, for example, fast syscall using sysenter/sysexit.
> 
> I'm happy to take a stab at this.
> 
> We still need someone to grab the context switch time keeping by the 
> horns and Do Something, though.

If I understand what was said earlier, the getmicrotime() kernel function ought 
to maintain the time at "(~ 1 msec)" precision.  Could getmicrotime() be 
exported as a syscall, so that we could do something like this:

--- lib/libc/gen/time.c~        Fri Jul 18 22:53:46 2003
+++ lib/libc/gen/time.c Fri Oct 28 13:04:26 2005
@@ -47,7 +47,8 @@
         struct timeval tt;
         time_t retval;

-       if (gettimeofday(&tt, (struct timezone *)0) < 0)
+       getmicrotime(&tt);
+       if (tt.tv_sec == 0)
                 retval = -1;
         else
                 retval = tt.tv_sec;

Note that this might even cause time(2) to return an error if the system is 
using dummyclock, which could be considered a feature.  :-)

-- 
-Chuck




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?43625ECE.7010804>