jackaudio / jack1

jack1 codebase
Other
250 stars 71 forks source link

Warning: cannot use real-time scheduling (FIFO at priority 10) (error=1: Operation not permitted) #72

Closed yurivict closed 2 years ago

yurivict commented 6 years ago

This warning is printed during every startup on the FreeBSD.

What happens is this:

  1. Jack starts with real-time priority
  2. jack_acquire_real_time_scheduling => process already runs at sufficient realtime priority
  3. jack_drop_real_time_scheduling is called with thread=27353088, now it has policy=SCHED_OTHER
  4. thread=27353088 spawns thread=27359488, both have policy=SCHED_OTHER
  5. thread=27353088 spawns thread=27360768, both have policy=SCHED_OTHER
  6. jack_acquire_real_time_scheduling is called in thread=27360768 and it fails, because it can't self-raise its priority, it can only lower it.

It should only lower priority of threads that don't later attempt to raise it again.

IMO, the logic is flawed here. Linux allows to raise priority of threads of root-owned processes, and jack assumes that everybody does the same, while BSD OSes don't allow to raise thread priority. There is rtprio(RTP_SET) for a process, and rtprio_thread(RTP_SET) for a thread.

I am not sure what would be the right fix here. It might be needed to replace pthread_setschedparam -> rtprio_thread.

0EVSG commented 2 years ago

Hi Yuri, closing this because

Regards, Florian