[Jack-Devel] Thread realtime priority

Yuri yuri at rawbw.com
Mon Jan 9 04:25:47 CET 2017


jackd on FreeBSD calls pthread_setschedparam(thread, SCHED_FIFO, 
&rtparam) with rtparam.sched_priority = 10.
I am wondering where does 10 come from? The range for SCHED_FIFO is 0 .. 
31, as returned by sched_get_priority_min() and 
sched_get_priority_max(). The value 10 seems wrong, since the fastest 
priority is 0, the slowest is 31.

In controlapi.c sched_get_priority_min()/sched_get_priority_max() are 
called for OpenBSD. For this purpose FreeBSD should be the same. So it 
should be #ifndef __OpenBSD__ && defined(__FreeBSD__).

Another problem is that FreeBSD doesn't allow to set thread priorities 
for non-root users, but jackd is supposed to run by the regular user. At 
least that's what libs expect it to be (/tmp/jack-{userid}). I have a 
suggestion: if the process is run with realtime priority, jackd 
shouldn't attempt to call pthread_setschedparam at all, because the 
process realtime priority should be sufficient.

This code:

struct rtprio rtp;
res = rtprio(RTP_LOOKUP, getpid(), &rtp);
if (rtp.type != RTP_PRIO_REALTIME) {
   // call pthread_setschedparam
}

allows to read priority of the process on FreeBSD.

The process can be run with realtime priority with this command: rtprio 
0 jackd ...


Yuri



More information about the Jackaudio mailing list