【发布时间】:2022-11-21 14:41:19
【问题描述】:
我正在尝试通过 pthread_setschedparam 将 Linux 线程优先级更改为实时 SCHED_FIFO。我收到错误“无许可”。
当进程在 root (sodo) 下执行时出现此错误。
将 Linux 线程优先级更改为实时 SCHED_FIFO 的正确方法是什么?
【问题讨论】:
标签: pthreads
我正在尝试通过 pthread_setschedparam 将 Linux 线程优先级更改为实时 SCHED_FIFO。我收到错误“无许可”。
当进程在 root (sodo) 下执行时出现此错误。
将 Linux 线程优先级更改为实时 SCHED_FIFO 的正确方法是什么?
【问题讨论】:
标签: pthreads
这个问题有两个原因。
首先,/etc/security/limits.conf 中没有配置用户限制。 应配置硬和软 rtprio。 这是一个例子:
我的用户名硬 rtprio 65
我的用户名软 rtprio 65
有关限制配置的详细信息可以在文件 limits.conf 中找到。
其次,内核 (usr/src/linux-headers-$(uname -r)/.config) 配置参数 CONFIG_RT_GROUP_SCHED 设置为 y。
为了使用带有 CONFIG_RT_GROUP_SCHED 的实时优先级,应该创建和配置相应的控制组(cgroup)。
看: [https://www.kernel.org/doc/Documentation/scheduler/sched-rt-group.txt][1] [https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/ch01 https://manpages.ubuntu.com/manpages/bionic/man7/cgroups.7.html ][2]
【讨论】: