线程编程在哪个操作系统上足以利用多个内核? [英] On which operationg system is threaded programming sufficient to utilize multiple cores?

查看:90
本文介绍了线程编程在哪个操作系统上足以利用多个内核?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用我的多线程编程技能(我掌握了技能),但是我意识到这还不够.如果操作系统不知道其潜力,我的线程可能仍会争用同一内核.我可以在Intel Xeon架构上使用哪种操作系统/编译器/库组合来连接到内核?

I would like to use my multi-threading programming skills (I got skills), but I realize that that is not enough. My threads may still compete for the same core if the operating system is not aware of the potential. What OS/compiler/library combination can I use on Intel Xeon architecture to thread to the cores?

推荐答案

所有现代OS均在所有可用内核上分配线程.但是有几种语言或库可以阻止这种情况的发生.最常见的问题是:

All modern OSs distribute threads on all available cores; but there are several languages or libraries that prevent this from happening. the most common issues are:

  • 绿色线程.当很少有多个CPU并且操作系统的优化不足时,它曾经具有性能优势.有几个Java VM吹嘘它是一项功能,后来转向M:N方案,我认为现在到处都是N:N.

  • green threads. it used to have a performance advantage when multiple CPUs were rare and OSs weren't optimised enough. there were a couple Java VMs that boasted this as a feature, later turned to M:N scheme, and i think it's now N:N everywhere.

GIL:全局解释器锁定.有些脚本语言在解释器循环中具有很多全局状态,因此只有一个大(互斥锁)以确保一致性.但这会阻止相同空间"的两个线程同时运行.至少Python和Lua都有此问题.在这种情况下,最好使用多个进程而不是多个线程.

GIL:Global Intepreter Lock. some scripting languages have a lot of global state deep in the interpreter loop, so there's a single big (mutex) lock to ensure consistency; but that prevents two threads of the same 'space' to run simultaneously. At least Python and Lua have this problem. in these cases it's preferred to use multiple processes instead of multiple threads.

另外,请记住,在大多数与CPU绑定的应用程序中,最大的瓶颈是RAM带宽,通常不是CPU本身,因此让多个线程争夺同一内存可能不是最佳设计.通常最好在几个通过小消息进行通信的单独流程中进行重构.

also, it's good to remember that the biggest bottleneck in most cpu-bound applications is the RAM bandwith, usually not the CPU itself, so having several threads fighting for the same memory might not be the best design. it's usually much better to refactor in several separate processes that communicate via small messages.

这篇关于线程编程在哪个操作系统上足以利用多个内核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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