gpt4 book ai didi

linux - QThread::start(priority) 与 Linux

转载 作者:太空狗 更新时间:2023-10-29 12:09:00 27 4
gpt4 key购买 nike

我在 KDE Neon 18.04(基于 Ubuntu 18.04,内核 4.15.0-46-generic)中使用一些基于 QThread 的工作线程。工作线程干扰了我的桌面应用程序,所以我决定降低它们的优先级。

QThread::start(priority) 的 Qt 文档说:

The effect of the priority parameter is dependent on the operating system's scheduling policy. In particular, the priority will be ignored on systems that do not support thread priorities (such as on Linux, see http://linux.die.net/man/2/sched_setscheduler for more details).

阅读上述文档后,我预计优先级不会对我的 Linux 系统产生影响。我还是试了一下。你猜怎么着 - 它工作得很好。

那么,为什么 Qt 文档声明在 Linux 上没有线程优先级?为什么它仍然有效?

最佳答案

根据您使用的 Linux/Unix/*Nix 风格,调度程序可能支持也可能不支持。据我所知,现在大多数 Linux 系统都支持 Qt 的大部分优先级,但不是所有的优先级。我怀疑文档说它不受支持,因此他们不需要列出支持优先级的操作系统变体和调度程序变体的每种组合以及支持哪些级别。

您可以通过使用 htoptop 并使用 awk 处理来验证它是否以正确的优先级创建它:https://unix.stackexchange.com/questions/19301/what-is-a-command-to-find-priority-of-process-in-linux

关于linux - QThread::start(priority) 与 Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55258248/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com