将特定线程绑定到特定的处理器核心 [英] Binding specific threads to specific processor cores

查看:176
本文介绍了将特定线程绑定到特定的处理器核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在大学里有点并行处理,现在我想更好地学习。我可以编写可以并行运行,然后启动线程的代码,但之后,我松开控制线程做什么。我想知道如何控制线程,例如绑定一个特定的线程到一个特定的处理器核心。

I've word a bit with parallel processing in college and now I'm trying to get better at it. I can write code that can run in parallel and then start up threads, but after that I loose control over what the threads do. I would like to know how I can control the threads to things like for example bind a specific thread to a specific processor core.

我最感兴趣的是c ++,但我'

I am mostly interested in c++ but I've done some coding of this in Java so those answers are also welcome.

推荐答案

我在Java透视中回答:这不是可能。您可以控制的最好的是线程优先级。要强制Java在某些CPU /内核上运行,必须以平台特定的方式来执行。例如,在Windows中,您可以在任务管理器中通过在进程选项卡中找到该进程,右键单击相关进程(通常 java.exe ),选择设置关联性并勾选CPU /内核。

I'm answering in Java perspective: That's not possible. The best what you can control is the thread priority. To force Java to run on certain CPU/core, you have to do it in a platform specific way. In Windows for example, you can do that in the task manager by locating the process in the Processes tab, rightclicking the process in question (usually java.exe), choosing Set Affinity and tick the CPU's/cores.

>

正如你可能猜到的,这确实是全局设置的亲和力,而不是基于你在Java中创建的线程。

As you might guess, this indeed globally sets the affinity, not on basis of threads you create in Java.

这篇关于将特定线程绑定到特定的处理器核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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