linux - 为什么 pthread_setschedparam() 在 opensuse 11.4 上生成 EPERM

标签 linux pthreads

我正在 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,&param);

结果 = 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/

相关文章:

linux - 为了安全起见,安装 Magento 后哪些文件应该是可写的?

linux - 数据迁移并从 Bitnami GitLab 8.9.6 升级到最新的 GitLab CE 综合总线

c++ - C++创建线程进程

c++ - 在 Linux 上中止线程 sleep

c++ - fork 并执行许多不同的进程,并从每个进程中获取结果

linux - 在Linux上同步2个文件

c++ - pthread_join() 在 C++ 中使用 pthreads 的逻辑错误

c - 将 pthread 作为输入并将其挂起的函数

c - 如何使用 PTRACE 获得多线程的一致 View ?

linux - 为什么 cat 会改变二进制文件的内容?