有没有一种方法来设置线程亲和力与处理器核心与boost线程库? [英] Is there a way to set thread affinity to a processor core with the boost thread library?

查看:524
本文介绍了有没有一种方法来设置线程亲和力与处理器核心与boost线程库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我需要的处理器内核在100%运行十几秒,或者如果我让系统决定如何处理线程,我会得到更好的性能,这是一个好主意吗?



我需要的是快速执行,我担心系统可能花费几秒钟之前使用所有的内核,但我还没有找到任何方法这样做与boost线程。 / p>

解决方案

您首先需要调用 get_native_handle 成员函数,然后将获取句柄到一个平台特定的函数来设置线程的CPU亲和力(即pthread_setaffinity_np / SetThreadAffinityMask /...).//p>

至于如果这是一个好主意:profile&找出...


And would it be a good idea to do so if I needed the processor cores running on 100% for a dozen seconds or would I get better performance if I let the system decide how to handle the threads?

What I need is fast execution and I'm worried the system might spend a few seconds before using all the cores, but I haven't found any way of doing this with boost thread.

解决方案

You'll first need to call the get_native_handle member function then pass the obtained handle to a platform specific function to set the thread's CPU affinity (i.e. pthread_setaffinity_np/SetThreadAffinityMask/...).

As to if that's a good idea: profile & find out...

这篇关于有没有一种方法来设置线程亲和力与处理器核心与boost线程库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆