I work with a virtual machine computer cluster with many amd64 processors and Debian Squeeze. Previously, I've successfully executed shell scripts in parallel on it (with GNU Parallel). Now, I'd like to use boost::threads. I run this program:
#include <boost/thread.hpp>
using namespace std;
boost::thread_group g;
void foo()
{
for(int i = 0; i < 1000000000; ++i)
for(int i = 0; i < 1000000000; ++i);
}
int main(int argc, char* argv[])
{
g.add_thread(new boost::thread(foo));
g.add_thread(new boost::thread(foo));
g.add_thread(new boost::thread(foo));
g.join_all();
}
All these threads run on a single processor, that is used in 300% (according to top
command). How to make these three threads to run on three separate processors? Is it possible with boost::threads?
Note: This Multiprocessor Boost::Thread? All threads running on one processor, despite the title, is about multicore system whereas mine is truly about multiprocessor system.