3

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

Amr ALHOSSARY
  • 196
  • 1
  • 14

1 Answers1

4

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.

Nicholas Pipitone
  • 4,002
  • 4
  • 24
  • 39