我正在 opensuse 11.4 上使用 c++ 和 NetBeans 编写一个应用程序,内核为 2.6.37.1-1.2 (以 root 身份登录)。该应用程序创建一个线程,运行时给出以下结果:
sched_param param;
param.__sched_priority = -1;
policy = SCHED_FIFO;
param.__sched_priority = 50;
result = pthread_setschedparam(m_thread,policy,¶m);
结果 = 1(EPERM(不允许))
为什么?
最佳答案
呃...因为这是不允许的?检查以下设置:
A non-privileged process cannot set the real-time priority higher than its RLIMIT_RTPRIO setting. You can change this with an "
rtprio
" entry in/etc/security/limits.conf
(settings are applied on login, so changes won't affect existing login sessions).Privilege is determined by the
CAP_SYS_NICE
capability.
配置文件中应该包含这样的内容:
domain type item value
@group soft rtprio 100
给定组的软 rtprio 限制为 100。 假设您的 PAM 配置使用 pam_limits,这将起作用。
您可能还必须确保硬限制:
@group hard rtprio 100
关于linux - 为什么 pthread_setschedparam() 在 opensuse 11.4 上生成 EPERM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8111302/