Taking advantage of both cores using C++

Discussion in 'MacBook Pro' started by vgoklani, Nov 2, 2006.

  1. vgoklani macrumors regular

    vgoklani

    Joined:
    Jul 2, 2004
    #1
    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.
     
  2. dusanv macrumors 6502

    Joined:
    Mar 1, 2006
    #2
    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.
     

Share This Page