什么是核心指定线程上运行? [英] What core is a given thread running on?

查看:254
本文介绍了什么是核心指定线程上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个函数或任何其他方式知道,编程,什么什么核心处理器的我的程序(PID)的一个给定的线程上运行?两者的OpenMP或Pthreads的解决方案将帮助我,如果可能的话。谢谢你。

Is there a function or any other way to know, programatically, what core of what processor a given thread of my program (pid) is running on? Both OpenMP or Pthreads solutions would help me, if possible. Thanks.

推荐答案

这将是平台特有的,我想。在Windows中可以使用 NtGetCurrentProcessorNumber ,但是这是需要注意的-ED为可能消失。

This is going to be platform-specific, I would think. On Windows you can use NtGetCurrentProcessorNumber, but this is caveat-ed as possibly disappearing.

我希望这是很难做到的,因为没有什么可以停止线程被转移到在任何时候一个新的核心(在大多数应用程序,反正)。只要你得到的结果,也可能是过时的。

I expect this is hard to do, because there's nothing to stop the thread being moved to a new core at any time (in most apps, anyway). As soon as you get the result, it could be out of date.

这篇关于什么是核心指定线程上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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