[linux-audio-dev] microsleeping

Lee Revell rlrevell at joe-job.com
Thu May 12 17:49:09 EDT 2005


On Thu, 2005-05-12 at 22:58 +0200, Tim Blechmann wrote:
> hi all..
> 
> i'm trying to sleep for some very low time slices ... about 100 to 1000
> us ...
> but i can't get below about 1 ms ... are there any workarounds to sleep
> for very small time slices?
> 

You can't sleep less than 1ms because that is the tick rate of the timer
interrupt.  For now the only universal "solution" is to busy-wait.

If your soundcard's timer is supported by the ALSA timer API (currently
only emu10k1 and ymfpci), you can get very good resolution: 1 tick at
48000Hz is 21 usecs.  Otherwise the ALSA timer resolution will only be
as good as the system timer.

> i tested nanosleep(), usleep() and select(0, 0, 0, 0, &timout) ...

The real solution, which is likely to end up in the mainline kernel, is
George Anzinger's high res timers patch:

http://sourceforge.net/projects/high-res-timers/

High res timers have been a hot topic on LKML lately.

Lee




More information about the linux-audio-dev mailing list