[Development] Thread priority on Linux - Qt 6.9.1

Art Greenberg art at artg.tv
Sat Jun 28 12:12:52 CEST 2025


Thanks Tim.

Is the RealtimeKit you're referring to the product from Cloudflare?

I happen to be doing bidirectional audio streaming. The server is a 
commercial embedded Linux device, a two-way radio:

https://elecraft.com/products/k4-transceiver

At the moment I don't see how the Cloudflare product applies. It looks 
like their API is tied in some way to their server platform.

Thank you both for your time. I'm content to use the work-around I 
described for now.

-- 
Art Greenberg
352-363-9002
art at artg.tv

On 6/27/25 22:34, Tim Blechmann via Development wrote:
>>> If not, please consider this suggestion: add a method to QThread that
>>> allows setting the scheduling policy, or allows setting the scheduling
>>> policy and priority in a single call similar to pthread_setschedparam().
>>
>> Sorry, the API in question is reserved for root. Since Qt applications 
>> are
>> almost always run as regular users, it would see very little use. 
>> Therefore, I
>> don't think we'll add it.
>>
>> For the few users who need it and know what they're doing, like you, 
>> you can
>> use the pthreads or Linux-specific API. You're probably doing enough code
>> reviews and static analyses anyway for your application running as 
>> root that
>> this is not an undue burden.
> 
> audio applications have to use rt scheduling for the audio thread(s), 
> unless one accepts glitches. jack or pipewire tend to grant the real- 
> time scheduling via @audio / @pipewire groups. afaict nowadays users can 
> also obtain realtime scheduling via RealtimeKit (which should come with 
> a watchdog thread).
> 
> ---
> 
> that said, real-time scheduling is always quite platform-dependent with 
> some parametrization involved: SCHED_FIFO/SCHED_RR use priority values, 
> SCHED_DEADLINE and THREAD_TIME_CONSTRAINT_POLICY use deadlines / time 
> constraints. on windows SetThreadPriority interacts with 
> SetPriorityClass, though there are also specialized scheduling classes 
> like MMCSS ...
> it's a bit difficult to wrap this into a QThread API



More information about the Development mailing list