* do_gettimeofday( ) precision?
@ 2004-06-23 15:23 abhijit
2004-06-23 15:54 ` Lukasz Michal Rak
0 siblings, 1 reply; 4+ messages in thread
From: abhijit @ 2004-06-23 15:23 UTC (permalink / raw)
To: linux-kernel
hello,
the comment on top of do_gettimeofday( ) [arch/i386/kernel/time.c] says:
/*
* This version of gettimeofday has microsecond resolution
* and better than microsecond precision on fast x86 machines with TSC.
*/
void do_gettimeofday(struct timeval *tv)
{
...
but the code below limits usec to <= 1000000. so isn't the resolution
not limited to microsec even on TSC capable boxes?
if one wants higher resolution (for timestamping etc.) whats the preferred
way?
thanks
abhijit
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: do_gettimeofday( ) precision?
2004-06-23 15:23 do_gettimeofday( ) precision? abhijit
@ 2004-06-23 15:54 ` Lukasz Michal Rak
2004-06-24 6:43 ` abhijit
0 siblings, 1 reply; 4+ messages in thread
From: Lukasz Michal Rak @ 2004-06-23 15:54 UTC (permalink / raw)
To: abhijit; +Cc: linux-kernel
On Wed, 23 Jun 2004, abhijit wrote:
> hello,
>
> the comment on top of do_gettimeofday( ) [arch/i386/kernel/time.c] says:
>
> /*
> * This version of gettimeofday has microsecond resolution
> * and better than microsecond precision on fast x86 machines with TSC.
> */
> void do_gettimeofday(struct timeval *tv)
> {
> ...
>
> but the code below limits usec to <= 1000000. so isn't the resolution
> not limited to microsec even on TSC capable boxes?
>
> if one wants higher resolution (for timestamping etc.) whats the preferred
> way?
>
> thanks
> abhijit
Hi!
I think you are right that do_gettimeofday() is limited to microsec even
on boxes with TSC register. This function returns only seconds and
microseconds so you won't get better resolution with it. I don't know the
way how to do it, but I wonder about precision of such mechanism (if any
exists).
Regards,
Lukasz
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: do_gettimeofday( ) precision?
2004-06-23 15:54 ` Lukasz Michal Rak
@ 2004-06-24 6:43 ` abhijit
2004-06-24 6:59 ` abhijit
0 siblings, 1 reply; 4+ messages in thread
From: abhijit @ 2004-06-24 6:43 UTC (permalink / raw)
To: Lukasz Michal Rak; +Cc: linux-kernel
On Wed, 23 Jun 2004 17:54:13 +0200 (CEST), Lukasz Michal Rak
<l.rak@elka.pw.edu.pl> wrote:
> I don't know the way how to do it, but I wonder about
> precision of such mechanism (if any exists).
basically i want some counter w/ microsend resolution that fits into 32 bits.
couple of possible solutions come to my mind:
[1] use TSC and convert it to microsec
[2] use get_timeofday( ) and convert to microsec
[3] use xtime variable directly and convert to microsec
(any other ways?)
conversion in [1] will be costly (a div involved).
conversion in [2]/[3] can be done using bit operators. (usec|sec << 20)
but [2] will incur function call overhead which i'd like to avoid.
so is using xtime directly ok and reliable?
thanks
abhijit
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: do_gettimeofday( ) precision?
2004-06-24 6:43 ` abhijit
@ 2004-06-24 6:59 ` abhijit
0 siblings, 0 replies; 4+ messages in thread
From: abhijit @ 2004-06-24 6:59 UTC (permalink / raw)
To: linux-kernel
On Thu, 24 Jun 2004 12:13:11 +0530, abhijit <slashdev@gmail.com> wrote:
>
> basically i want some counter w/ microsend resolution that fits into 32 bits.
> couple of possible solutions come to my mind:
>
> [1] use TSC and convert it to microsec
> [2] use get_timeofday( ) and convert to microsec
> [3] use xtime variable directly and convert to microsec
> (any other ways?)
>
> conversion in [1] will be costly (a div involved).
> conversion in [2]/[3] can be done using bit operators. (usec|sec << 20)
> but [2] will incur function call overhead which i'd like to avoid.
>
> so is using xtime directly ok and reliable?
ok. after reading up the source, i think xtime isn;t updated frequently and will
not have the required resolution :( so calling do_gettimeofday() seems the only
way out (unless somebody has any other idea).
btw why isn't do_gettimeofday( ) declared as "inline". so its bit
cheaper to call
especially where you are timestamping (say packets) often.
thanks
abhijit
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-06-24 6:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-23 15:23 do_gettimeofday( ) precision? abhijit
2004-06-23 15:54 ` Lukasz Michal Rak
2004-06-24 6:43 ` abhijit
2004-06-24 6:59 ` abhijit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox