繁体   English   中英

在 windows 上设置与 pthread 的关联

[英]Set affinity with pthread on windows

我使用 c++ 在 windows 7 上开发了一个应用程序。 我正在为线程使用 gnu pthread 库。 我需要将我的线程之一设置为核心。

#define _GNU_SOURCE
#include <iostream>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int myfuction() 
{
    cpu_set_t cpuset;
    .... 

} 

我有一个错误:在这个 scope 中没有声明“cpu_set_t”

我找不到原因。 所以你知道如何解决这个问题,或者你有一些代码可以达到这个目的。?

谢谢你的帮助!

我相信你需要

#include <sched.h>

参考: https://www.sourceware.org/pthreads-win32/manual/cpu_set.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM