Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Pthread and multiple CPU

  1. Mar 7, 2006 #1

    First question is:
    I want to assign 8 threads to 8 processors (must one to one), when I initialize the thread, does it guarantee that each CPU has one thread?
    or there can be some case such that 4 threads on one process and other 4 thread on 4 processors and 3 processors have no threads at all?

    Second question is:
    For instance, one processor has 4 jobs running, is it possible to shift 2 of them to other processors? using IPC stuffs? or other methods?

    For the above questions, is there any reference links that I can visit?
    I am new to threading. Thanks ahead to anyone answer my questions.
  2. jcsd
  3. Mar 9, 2006 #2


    User Avatar
    Science Advisor

    In C, using Posix threads, you can use pthread_processor_bind_np() to associate a thread to a specific processor. Using cthreads it's something like cthreads_thread_alloc(..., node) where node is the processor to run on.
    If you don't specify, then the thread will probably run on a processor chosen depending on the OS scheduling algorithm i would imagine.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook