[linux-audio-dev] timesetevent alternative

Benno Senoner sbenno at gardena.net
Sun May 8 16:22:46 UTC 2005

Hi Lee,
But what's the exact behaviour in 2.6 kernels then ?
Does nanosleep() provide non-busywait usec precision using hires timers, 
or does it simply do the same as usleep() ?
Eg providing only 1/HZ precison.


Lee Revell wrote:

>>nanosleep() might be a bit more precise than usleep() but for low sleep 
>>values ( AFAIK < 2msec ) it
>>busywaits when you run your app SCHED_FIFO which in the case of 
>>sustained streams of low sleep values
>>could chew up all the CPU, not idea for real time audio apps.
>Not anymore.  From man 2 nanosleep:
>   Old behaviour
>       In  order to support applications requiring much more precise
>pauses (e.g., in order to control some time-critical hardware),
>nanosleep would handle pauses of up
>       to 2 ms by busy waiting with microsecond precision when called
>from a process scheduled under a real-time policy  like  SCHED_FIFO  or
>SCHED_RR.   This  special
>       extension was removed in kernel 2.5.39, hence is still present in
>current 2.4 kernels, but not in 2.6 kernels.

More information about the Linux-audio-dev mailing list