Boost线程、Posix线程和STD线程,为什么它们提供不同的性能?

Boost thread, Posix thread and STD thread, why do they offer different performances?

据我所知,

In computer science, a thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system. The implementation of threads and processes differs between operating systems, but in most cases a thread is a component of a process. Multiple threads can exist within one process, executing concurrently and sharing resources such as memory, while different processes do not share these resources. In particular, the threads of a process share its executable code and the values of its variables at any given time.[1]

当我决定用 C++ 编写多线程程序时,我面临着许多选择,例如 boost 线程、posix 线程和 std 线程。

互联网上的简单搜索显示了 boost.org website here 进行的性能测量。

我的问题比较基础,也与性能有关。

基本上,为什么它们的性能不同?为什么,例如线程类型 A,比其他线程快?它们由大多数专业程序员编写,由功能强大的操作系统 运行 编写,但它们提供不同的性能。

是什么让它们更快或更慢?

Boost 文档引用了 Fiber 库,它实际上不是线程。创建库中称为纤程的东西(本质上是用户 space 线程或协程,有时也称为绿色线程)不会在内核端创建单独的可调度实体,因此创建效率更高时间。其他事情可能效率较低,因为 I/O 操作在该模型下必然变得更加复杂(因为执行 I/O 的纤程不应阻塞它运行的操作系统线程,如果其他纤程可以在那里工作的话)。

请注意,一些协程实现超出了事实上的 GNU/Linux ABI 和其他 POSIX 类操作系统的概念限制,因此它们应该被认为是丑陋的充其量是黑客。