[linux-audio-dev] real time priority programming tutorial

Christian Schoenebeck cuse at users.sourceforge.net
Mon Jun 5 16:38:19 UTC 2006


Am Montag, 5. Juni 2006 16:12 schrieb Steve:
> Here is essentially the code I have been using for this purpose.
> You don't necessarily need to use max priority for sp.sched_priority.
> There may be better ways of doing this, I guess... if anyone sees if
> I'm missing something. Seems to work, but has the disadvantage of
> having to run under "sudo" to gain the priority.

Depends on your system configuration. I don't have to call it as super user on 
my system.

> I'm not 100% sure if the mlockall call is necessary.

mlockall avoids memory swapping, so as long as you haven't completely turned 
off swapping in your system it's definitely a good idea to call mlockall in a 
RT sensitive process.

If you're not a C++ hater, here's a general purpose "Thread" class which can 
be used for RT threads and low priority threads as well:

http://cvs.linuxsampler.org/cgi-bin/viewcvs.cgi/linuxsampler/src/common/Thread.h
http://cvs.linuxsampler.org/cgi-bin/viewcvs.cgi/linuxsampler/src/common/Thread.cpp

Just derive from that abstract "Thread" class and implement the virtual 
method "int Main()" in your class.

CU
Christian



More information about the Linux-audio-dev mailing list