2005-05-10 20:27:39

by Andre Eisenbach

[permalink] [raw]
Subject: High res timer?

Hello!

We're currently using pth_usleep() as a timer for a userspace audio
application. However, it doesn't seem very accurate and reliable. Is
there a better (more accurate) timer that we can call form a userspace
application?

Thanks,
Andre


2005-05-10 20:42:43

by Lee Revell

[permalink] [raw]
Subject: Re: High res timer?

On Tue, 2005-05-10 at 13:27 -0700, Andre Eisenbach wrote:
> Hello!
>
> We're currently using pth_usleep() as a timer for a userspace audio
> application. However, it doesn't seem very accurate and reliable. Is
> there a better (more accurate) timer that we can call form a userspace
> application?

Why don't you just clock off the sound card?

Lee

2005-05-10 20:42:45

by Lee Revell

[permalink] [raw]
Subject: Re: High res timer?

On Tue, 2005-05-10 at 13:27 -0700, Andre Eisenbach wrote:
> Hello!
>
> We're currently using pth_usleep() as a timer for a userspace audio
> application. However, it doesn't seem very accurate and reliable. Is
> there a better (more accurate) timer that we can call form a userspace
> application?
>

Also, this is a bit OT for LKML. Try linux-audio-dev at
music.columbia.edu. You can probably find several good ways to do it in
the archives.

Lee

2005-05-10 20:49:18

by Matthias-Christian Ott

[permalink] [raw]
Subject: Re: High res timer?

Andre Eisenbach wrote:
> Hello!
>
> We're currently using pth_usleep() as a timer for a userspace audio
> application. However, it doesn't seem very accurate and reliable. Is
> there a better (more accurate) timer that we can call form a userspace
> application?
>
> Thanks,
> Andre
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
What about nanosleep ()?

Matthias-Christian

2005-05-10 21:19:09

by Andre Eisenbach

[permalink] [raw]
Subject: Re: High res timer?

2005/5/10, Lee Revell <[email protected]>:
> On Tue, 2005-05-10 at 13:27 -0700, Andre Eisenbach wrote:
>
> Why don't you just clock off the sound card?
>

I'll look into this.

Oh, and sorry for the off-topic :(

Thanks,
Andre

2005-05-10 21:20:17

by Andre Eisenbach

[permalink] [raw]
Subject: Re: High res timer?

2005/5/10, Matthias-Christian Ott <[email protected]>:
>
> What about nanosleep ()?
>

nanosleep() seems to have some latency very similar to usleep(). Isn't
usleep based on nanosleep()?

Here's what I get if I try to nanosleep for 5 secs (for testing):

-> 5.009952 s

The .009952 part varies, but is very close to that usually.

Thanks,
Andre

2005-05-10 21:29:29

by Lee Revell

[permalink] [raw]
Subject: Re: High res timer?

On Tue, 2005-05-10 at 14:16 -0700, Andre Eisenbach wrote:
> 2005/5/10, Matthias-Christian Ott <[email protected]>:
> >
> > What about nanosleep ()?
> >
>
> nanosleep() seems to have some latency very similar to usleep(). Isn't
> usleep based on nanosleep()?
>
> Here's what I get if I try to nanosleep for 5 secs (for testing):
>
> -> 5.009952 s
>
> The .009952 part varies, but is very close to that usually.

Is this a 2.4 kernel? The resolution on 2.6 should be 1ms, not ~10ms.

Lee

2005-05-10 21:42:48

by Andre Eisenbach

[permalink] [raw]
Subject: Re: High res timer?

2005/5/10, Lee Revell <[email protected]>:
> > Here's what I get if I try to nanosleep for 5 secs (for testing):
> >
> > -> 5.009952 s
> >
> > The .009952 part varies, but is very close to that usually.
>
> Is this a 2.4 kernel? The resolution on 2.6 should be 1ms, not ~10ms.

Yes indeed, that was a 2.4 kernel. On 2.6 (different machine though) I get:

-> 5.001064 s

Thanks,
Andre

2005-05-11 01:18:59

by George Anzinger

[permalink] [raw]
Subject: Re: High res timer?

Andre Eisenbach wrote:
> Hello!
>
> We're currently using pth_usleep() as a timer for a userspace audio
> application. However, it doesn't seem very accurate and reliable. Is
> there a better (more accurate) timer that we can call form a userspace
> application?

You don't say what resolution you want, but to ~ 1 ms, nanosleep or
clock_nanosleep should work. If you need better resolution, check out the HRT
patch, see sig. below.

--
George Anzinger [email protected]
High-res-timers: http://sourceforge.net/projects/high-res-timers/