linux-mips
[Top] [All Lists]

Re: Getting Time Difference

To: Gilad Benjamini <gilad@riverhead.com>
Subject: Re: Getting Time Difference
From: Jun Sun <jsun@mvista.com>
Date: Tue, 21 Jan 2003 10:13:38 -0800
Cc: Gilad Benjamini <yaelgilad@myrealbox.com>, linux-mips@linux-mips.org, jsun@mvista.com
In-reply-to: <328392AA673C0A49B54DABA457E37DAA08C300@exchange>; from gilad@riverhead.com on Tue, Jan 21, 2003 at 07:48:57AM +0200
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <328392AA673C0A49B54DABA457E37DAA08C300@exchange>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.2.5i
On Tue, Jan 21, 2003 at 07:48:57AM +0200, Gilad Benjamini wrote:
> > In mvsita kernel we introduced an abstraction layer which consists
> > of the following:
> > 
> > readclock_init()
> > readclock()
> > clock_to_usecs()
> > 
> > For MIPS in general, we use the following implementation:
> > 
> > #define readclock_init()
> > #define readclock(low)   do {                           \
> >         db_assert(mips_cpu.options & MIPS_CPU_COUNTER); \
> >         low = read_32bit_cp0_register(CP0_COUNT);       \
> >         } while (0)     
> > #define clock_to_usecs(clocks) ((clocks) / 
> > ((mips_counter_frequency / 1000000)))
> > 
> 
> Thx.
> How would I go about doing readclock to a 64 bit variable ?
> The 32 bit can wrap around pretty fast in today's processors.
>

This interface is meant for short and precise kernel timing
measurement.  Wraping around once does not cause problem as
long as the elapsed clock cycles is less than 2^32.  That gives 
you about 40 secs max interval on a CPU with 100MHz counter
frequency.

Jun

<Prev in Thread] Current Thread [Next in Thread>