我有以下代码,它改变了当前线程的优先级。我传递了 90 作为参数,但看起来线程正在以优先级 19 运行。我有:
- 检查 ulimit -r 是否设置为 99
- 进程以root身份运行
我怎么知道该进程以优先级 19 运行。我执行了以下命令。如您所见,pri 是 19。rtprio 和 pri 之间有什么区别?我正在使用来自 redhat Enterprise linux 6.3 版的 2.6 内核。因为,这不是实时 linux,所以if(pthread_setschedparam(pthread_self(), SCHED_RR, ¶m))
当我将调度程序设置为时,这一行在代码中是否有效SCHED_RR
ps -p 10834 -o pid,tid,class,rtprio,ni,pri,psr,pcpu,stat
PID TID CLS RTPRIO NI PRI PSR %CPU STAT
10834 10834 TS - 0 19 9 99.9 R+
void changePriority(int tPriority)
{
int policy;
struct sched_param param;
pthread_getschedparam(pthread_self(), &policy, ¶m);
param.sched_priority = tPriority;
if(pthread_setschedparam(pthread_self(), SCHED_RR, ¶m))
err_sys("error while setting thread priority to %d", tPriority);
}