[英]Set affinity with pthread on windows
I develop an application on windows 7 with c++.我使用 c++ 在 windows 7 上开发了一个应用程序。 I am using gnu pthread library for threads.
我正在为线程使用 gnu pthread 库。 I need to set affinity one of my thread to a core.
我需要将我的线程之一设置为核心。
#define _GNU_SOURCE
#include <iostream>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int myfuction()
{
cpu_set_t cpuset;
....
}
I have an error: 'cpu_set_t' was not declared in this scope我有一个错误:在这个 scope 中没有声明“cpu_set_t”
I couldnt find the reason.我找不到原因。 So you have an idea how to solve this problem, or do you have some piece of code for this aim.?
所以你知道如何解决这个问题,或者你有一些代码可以达到这个目的。?
Thanks for your help!谢谢你的帮助!
I believe you need我相信你需要
#include <sched.h>
Reference: https://www.sourceware.org/pthreads-win32/manual/cpu_set.html参考: https://www.sourceware.org/pthreads-win32/manual/cpu_set.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.