[Development] Thread priority on Linux - Qt 6.9.1
Thiago Macieira
thiago.macieira at intel.com
Sat Jun 28 00:05:56 CEST 2025
On Friday, 27 June 2025 21:53:24 Central European Summer Time Art Greenberg
wrote:
> I am able to overcome that limitation by obtaining the thread handle
> returned by QThread::currentThreadId() and using the native pthreads
> API. I am aware that this is not suggested in application code.
Actually, no, that's perfectly fine. You an also get the thread's TID and use
sched_setscheduler(2).
> So, my question. Is there a way to set thread scheduling policy
> provided, such that changing the priority will work? A pointer to the Qt
> documentation would be appreciated.
>
> 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.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Principal Engineer - Intel Platform & System Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5150 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20250628/3ea87879/attachment.bin>
More information about the Development
mailing list