多核编码
我正在编写这个 C++ 应用程序,它使用 Boost 线程和 SFML 来使用 TCP 和 UDP 套接字。我有一个 4 代码 Xeon CPU,但似乎我只使用 1 个核心。我怎样才能获得完整的 4 个核心?
I'm writing this c++ application that uses Boost threading and SFML to use TCP and UDP sockets. I have a 4 code Xeon CPU but it seems like I'm using only 1 core. How can I get access to the full 4 cores?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
线程分配取决于您所使用的操作系统。另请告诉我“但看起来我只使用 1 个核心”到底是什么意思。
不过,您可以做一些研究:
如果您使用的是 Windows,有一个不错的程序可以显示您的应用程序中正在运行多少个线程,哪个线程与特定的硬件核心和使用情况相关联(单击属性和线程选项卡):
http://technet.microsoft.com/en-us/sysinternals/bb896653
您的线程实际上执行什么类型的工作?也许您有一些竞争条件,例如线程饥饿等。
据我所知,仅让多个线程发送一些数据是没有意义的,因为所有数据都通过内核驱动程序传输并在最后进行序列化。
BR
Thread assignment is up to the OS you are using. Also please tell what do you mean by "but it seems like I'm using only 1 core" exactly.
However you can do some research:
If you are using Windows there is a nice program that will show you how many threads are running in your application, which thread is associated to specific HW core and usage (click properties and threads tab):
http://technet.microsoft.com/en-us/sysinternals/bb896653
What kind of work is actually performed by your threads? Maybe you have some race condition like threads starvation etc.
AFAIK there is no sense in making several threads to send some data only because all data is traveling through kernel driver and is serialized at the end.
BR