Re: usleep() and nanosleep() timings seem inaccurate using ALSA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At Thu, 29 Mar 2007 17:46:38 +0800,
Carlo Florendo wrote:
> 
> Good Day!
> 
> After studying the intricacies of MIDI, I ended up writing an 
> implementation of the MIDI protocol and file format.
> 
> I then studied the ALSA sequencer API to be able to control a synthesizer 
> keyboard and play MIDI files.  I've used aplaymidi, aconnect, arecordmidi, 
> and all those great ALSA utilities.  They're very good!
> 
> However, I wanted to have a simple ncurses based, command line MIDI 
> sequencer meant for small Linux distributions such as DSL or Trustix so I 
> began to write a command line sequencer using ALSA.  I've encountered one 
> problem about using usleep() and nanosleep() especially in 2.4 kernels.

You cannot get a small sleep usually on user-space processes.
Usually, usleep() is implemented with select/poll and its timeslice is
defined by HZ in kernel config.  In most cases, it's HZ=100, 250 or
1000 while 2.4-i386 kernel supports only HZ=100.  That is, the least
sleep time is 10ms no matter what value you pass to usleep().

This can be overcome by using a realtime schedule class and priority
like JACK does.


Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux