简体   繁体   中英

BOOST threads: threads or processes?

Are BOOST threads (around version 1.49) real threads or separate processes?

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).

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. They share memory just like Copy-on-Write , but without the copying. 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). 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. Nothing is different under-the-hood.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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