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

Question on Threads

  1. Apr 5, 2007 #1
    Hiya :),
    1). I understand that threads are like processes except that they share the state information, and memory.
    So I would think they share the values of the registers, the memory heap, and the stack, right? would they also share global variables?

    2). Also, could a multithread solution that uses multiple user threads get better performance on a multiprocessor system than on a system with only 1 processor? I think it could get better performance if indeed we assign a thread to each processor, but I’m not sure whether the user level thread can allocate this processors or not?

    Thanks in advance for any help

  2. jcsd
  3. Apr 5, 2007 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    There are many different thread implementations, and they can actually differ in many respects. The most ubiquitous threading system is probably pthreads (POSIX threads), which is described here:


    Note that pthreads share only the heap; they each have their own stack. Registers are not preserved across thread context switches, either.

    The answer to your last question depends on the implementation. If the threads are implemented entirely in user space, they cannot be distributed across multiple processors. If the threads are implemented by the operating system kernel, on the other hand, they generally can be distributed across multiple processors.

    - Warren
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?