linux-mips
[Top] [All Lists]

Re: Getting Time Difference

To: Gilad Benjamini <yaelgilad@myrealbox.com>
Subject: Re: Getting Time Difference
From: Jun Sun <jsun@mvista.com>
Date: Mon, 20 Jan 2003 11:50:59 -0800
Cc: linux-mips@linux-mips.org, jsun@mvista.com
In-reply-to: <ECEPLLMMNGHMFBLHCLMAGEGDDIAA.yaelgilad@myrealbox.com>; from yaelgilad@myrealbox.com on Thu, Jan 16, 2003 at 06:48:09PM +0200
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <ECEPLLMMNGHMFBLHCLMAGEGDDIAA.yaelgilad@myrealbox.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.2.5i
On Thu, Jan 16, 2003 at 06:48:09PM +0200, Gilad Benjamini wrote:
> Hi,
> I am porting code from a x86 platform.
> That code uses rdtsc and cpu_khz to compute
> the time difference between two events. Jiffies aren't good enough in this 
> case.
> 
> Looking through header files I can find a few MIPS replacements.
> What is the "right" one to use ?
> 
> What is the best way to change the code so it can compile
> and run on both platforms ?
>

I assume you are doing this inside kernel for some performance
measurement.

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)))

In mvl kernel we always calibrate mips_counter_frequency even if it
is not specified by board code.  This is different from the current
linux-mips.org tree.

Jun 

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