Alsa thread priority

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

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…

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.

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?


Well on linux, yes :slight_smile: just look at Process::setPriority in , it is using pthread_self() to set the priority.

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