Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vgoklani

macrumors regular
Original poster
Jul 2, 2004
186
0
Hi,

I wrote a small simulation in C++, and upon execution, I noticed that only one of the two cores was doing the actual processing (courtesy of menumeters). Is there a way to take advantage of both cores, ie: is there some sort of compiler flag that I am supposed to use?

This is how I compiled my code:

g++ simulated_annealing.cpp

some background info: I am running everything from within terminal, and I have the latest version of XCode installed (hence I am using gcc 4.01). I am running all this on my Macbook Pro.
 
Open your favourite terminal app and type:

man pthread_create

Look into learning how to program with threads (pthreads). There are a bunch of nice books on the topic available.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.