cpu_set_t mask;
CPU_ZERO(&mask);
struct sched_param param;
pthread_attr_t attr;
int policy,inher;
pthread_attr_init(&attr);
pthread_attr_getschedpolicy (&attr, &policy);
pthread_attr_getinheritsched(&attr,&inher);
param.sched_priority = 99;
pthread_attr_setschedpolicy(&attr, policy);
sched_setscheduler(pthread_self(), policy, ¶m);
CPU_SET(2, &mask);
if (pthread_setaffinity_np(pthread_self(), sizeof(mask),&mask) < 0) {
perror("bind cpu");
}
linux优先级与调度设定
最新推荐文章于 2023-08-04 22:00:55 发布