我创建了两个线程。默认情况下,他们有一个优先级,我可以使用 pthread_getschedparam 看到,然后0
我尝试分别提高他们的优先级。但是当我尝试这样做时,我得到了一个错误2
3
error setting priority for T1: (1), Operation not permitted
error setting priority for T2: (1), Operation not permitted
我已经SCHED_RR
为他们使用了调度策略
int sched = SCHED_RR;
然后执行此操作:-
if (pthread_setschedparam(t1, sched, &t1_param) != 0)
{
std::cout << "error setting priority for T1: (" << errno << "), " <<
strerror(errno) << std::endl;
}
我无法修改线程优先级的原因是什么,因为优先级在 SCHED_RR 的限制范围1
内99
。