Re: [linux-audio-dev] gettimeofday() realtime safe?

From: Lee Revell <rlrevell@email-addr-hidden-job.com>
Date: Thu Apr 21 2005 - 17:28:28 EEST

On Thu, 2005-04-21 at 11:28 +0200, David Olofson wrote:
> On Thursday 21 April 2005 07.45, Jack O'Quin wrote:
> [...]
> > > Is calling gettimeofday this many times in the realtime thread a
> > > wise idea?
> >
> > How often? Once per MIDI event? That should be OK, I suppose.
>
> I did a quick hack for testing some custom hardware on an embedded
> system, where I just polled gettimeofday() to get some code to run at
> 10 kHz. (Didn't care about the occasional stalls - which were very
> few anyway, as this was the only process actually doing anything at
> the time.) That is, a bunch of gettimeofday() calls for each loop,
> times 10 kHz. Worked just fine.
>
> This was on a 300 MHz low power Pentium clone, which has about 10-15%
> of the power of a 1 GHz P-III CPU. I'm not even sure if Linux is
> using RDTSC for gettimeofday() on this thing...

Yes, Linux implements gettimeofday via rdtsc() on x86. I think it may
use the ACPI PM timer under some conditions also. Which is why if you
can get away with just using rdtsc directly for timing it's better than
gettimeofday.

Lee
Received on Thu Apr 21 20:15:04 2005

This archive was generated by hypermail 2.1.8 : Thu Apr 21 2005 - 20:15:05 EEST