ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you really want to run a real-time thread in your application, skip pthread and just use boost::thread instead. You can find the docs here. It's simple, clean, and ROS uses it all over the place.

If you really want to run a real-time thread in your application, skip pthread and just use boost::thread instead. You can find the docs here. It's simple, clean, and ROS uses it all over the place.

EDIT:

You can run as many threads in a process as you want, but there are only certain conditions under which these threads will run at full performance. boost::thread will use multiple cores by default, but if your threads do less work than scheduling the thread then you won't see any benefit from multithreading. Also, if you have more threads than cores, you won't see much performance increase.

Other than that, there's no reason that you can't run multiple threads in a single process.

Just an aside: ROS runs each node as a separate process to enable maximum operating system optimization (processes are typically handled and scheduled better than threads). You could look into splitting your real-time process into multiple nodes.