在Cygwin中#define _GNU_SOURCE?

时间:2017-05-03 05:25:54

标签: c++ multithreading pthreads cygwin affinity

我在编译时尝试使用-D_GNU_SOURCE,但两者都不起作用,我试图使用pthread_setaffinity_np和其他多线程功能,但编译器说它超出了范围。这就是我所拥有的:

#define _GNU_SOURCE
#include <sched.h>
int cpuAff(){ //set processor affinity
    cpu_set_t cpuset;
    CPU_ZERO(&cpuset);
    CPU_SET(0, &cpuset);
    pthread_setaffinity_np(threads[0], sizeof(cpu_set_t), &cpuset);
    pthread_setaffinity_np(threads[1], sizeof(cpu_set_t), &cpuset);
    pthread_setaffinity_np(threads[2], sizeof(cpu_set_t), &cpuset);
    pthread_setaffinity_np(threads[3], sizeof(cpu_set_t), &cpuset);
}

如果是问题,我在Windows 10上使用cygwin?任何人都知道修复?

0 个答案:

没有答案