li********@gmail.com skrev:
I used a boost multi thread in VS 2005 on a Duo Core PC, and made a two
thread process.
The code is something like this:
#include <boost/thread/thread.hpp>
void fun1()
{
//do something
}
void fun2()
{
//do something
}
int _tmain(int argc, _TCHAR* argv[])
{
boost::thread thrd(&fun1);
boost::thread thrd2(&fun2);
thrd.join();
thrd2.join();
return 0;
}
It can run, but run on only one of the two cores. The CPU usage is 50%.
Isn't that multi-thread can improve proformance on multi-core CPU?
If only one cpu is used and both fun1 and fun2 are doing something
measurable (that is the operations are "substantial"), there is
something wrong somewhere. One thing that could go wrong is that the
two functions depend on each other, so that when fun1 runs fun2 can not
possibly run.
My suggestion would be that you tried to perform some dummy
calculations in the functions (e.g. calculating some million
trigonometric results on local values). If only cpu is used in this
case, you should ask further in a some group related to boost
(comp.boost.users?) or one related to the operating system you use.
/Peter