Pthread_setaffinity_np 无效参数
我正在尝试更改启动例程内每个线程的亲和力。
这是代码。在下面的代码中,“t”是通过 pthread_create 函数传递的参数。
cpu_set_t mask;
pthread_t c;
a = *((int *)t);
printf(" thread no. is %d \n",a);
CPU_ZERO(&mask);
a =a/2 + 1;
CPU_SET(a,&mask);
c=pthread_self();
s=pthread_setaffinity_np(c,sizeof(cpu_set_t), &mask);
if (s!=0)
handle_error_en(s,"pthread_setaffinity_np");
线程关联性没有改变。我哪里出错了?
I am trying to change the affinity of each thread inside the start routine.
Here's the code. In the below code, 't' is the argument passed through the pthread_create function.
cpu_set_t mask;
pthread_t c;
a = *((int *)t);
printf(" thread no. is %d \n",a);
CPU_ZERO(&mask);
a =a/2 + 1;
CPU_SET(a,&mask);
c=pthread_self();
s=pthread_setaffinity_np(c,sizeof(cpu_set_t), &mask);
if (s!=0)
handle_error_en(s,"pthread_setaffinity_np");
The thread affinity is not getting changed. Where am I going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我误解了面具的界限。那就是我出错的地方。
I had misunderstood the bounds of the mask. That was where I was going wrong.