简体   繁体   English

BOOST线程:线程还是进程?

[英]BOOST threads: threads or processes?

Are BOOST threads (around version 1.49) real threads or separate processes? BOOST线程(版本1.49左右)是真正的线程还是单独的进程?

When I had run a precompiled version of a docking tool, it looked like several processes (with different process IDs and 100% CPU usage each) using top, but when I compiled it myself (using BOOST version 1.60), they look like one process (with a single process ID and 800% CPU usage). 当我运行一个预编译版本的对接工具时,它看起来像是使用top的几个进程(具有不同的进程ID和100%的CPU使用率),但是当我自己编译它时(使用BOOST版本1.60),它们看起来像一个进程(使用单个进程ID和800%的CPU使用率)。

It shouldn't affect performance, if that's what you're worried about. 它不应该影响性能,如果这是你担心的。 Linux has offered multithreading in the form of separate processes for a long time. Linux已经在提供了很久独立进程的形式,多线程。 They share memory just like Copy-on-Write , but without the copying. 它们像Copy-on-Write一样共享内存,但没有复制。 Top may organize it differently when it knows that the threads are supposed to be grouped together, due to using a more recent Linux call , but "real" threads still are separate processes (run top -H to see the threads as the kernel sees them). 当由于使用更新的Linux调用而知道线程应该被组合在一起时,Top可以以不同的方式组织它,但是“真正的”线程仍然单独的进程(运行top -H以在内核看到它们时查看线程)。 They are scheduled independently, and in the eyes of the kernel have nothing in common other than some overlapping memory pages (After initializing the memory pages, the kernel has no idea after, and it doesn't really care). 它们是独立安排的,并且在内核的眼中除了一些重叠的内存页面之外没有任何共同之处(在初始化内存页面之后,内核不知道之后,它并不真正关心)。

So yeah, older versions of boost might've used separate "processes" instead of "threads", but that's all semantics anyway. 所以是的,旧版本的boost可能会使用单独的“进程”而不是“线程”,但无论如何这都是语义。 Nothing is different under-the-hood. 引擎盖下没有什么不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM