在另一个内核创建线程? (WinAPI的) [英] creating thread on another core? (WinAPI)

查看:142
本文介绍了在另一个内核创建线程? (WinAPI的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有一种方式来运行在一个单独的核心,而不是只在该核心线程一个线程?
谢谢

I was wondering if there was a way to run a thread on a seperate core instead of just a thread on that core? Thanks

推荐答案

如果你创建一个线程,你必须在默认情况下无法控制哪些核心它将运行。操作系统的调度算法需要照顾这一点,在其工作pretty不错。但是,您可以使用 SetThreadAffinity WinAPI的指定逻辑内核线程被允许运行。

If you create a thread, you have by default no control on which core it will run. The operation system's scheduling algorithm takes care of that, and is pretty good at its job. However, you can use the SetThreadAffinity WinAPI to specify the logical cores a thread is allowed to run on.

不这样做,除非你有很好的理由。引述MSDN:

Don't do that unless you have very good reasons. Quoting MSDN:

设置具有亲和性掩码进程或线程可以导致接收更少的处理器时间,因为该系统从上某些处理器上运行的线程限制线程。在大多数情况下,最好是让系统选择一个可用的处理器。

Setting an affinity mask for a process or thread can result in threads receiving less processor time, as the system is restricted from running the threads on certain processors. In most cases, it is better to let the system select an available processor.

这篇关于在另一个内核创建线程? (WinAPI的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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