Alsa thread priority


#1

Hi Jules,

What do you think of adding Process::setPriority(Process::RealtimePriority); at the beginning of AlsaThread::run() ? That way it sets the thread to realtime SCHED_RR policy , which helps a lot to prevent cracklings. Of course it works only when the user account is allowed to set realtime scheduling in /etc/security/limits.conf


#2

Well, changing the process priority like that is really something I’d rather leave for the app itself to choose to do. If you were writing a sequencer, it’s probably something you’d do, but you may not want your app to have such a high priority…


#3

I agree indeed, but it is not easy to do here, because I want to set realtime priority only on the alsa thread, not on the whole process (on linux juce::Process:setPriority changes the priority of the current thread, not the whole process). So the only way to do that right now is to hack into AlsaThread code , which is not excessively clean. But I understand your point.


#4

Whoa - what was that about Process::setPriority? Does that mean when I set that at the start of my app, I’m actually just boosting my main thread?

That would have the opposite affect than I need - it would make it beat my threads I specifically set higher, right?

Bruce


#5

Well on linux, yes :slight_smile: just look at Process::setPriority in http://juce.svn.sourceforge.net/viewvc/juce/trunk/build/linux/platform_specific_code/juce_linux_Threads.cpp?revision=632&view=markup , it is using pthread_self() to set the priority.

Maybe it should be replaced by a renice() call .