Multi-threading in Mac OS X

Discussion in 'Java' started by murali, Sep 13, 2003.

  1. murali

    murali Guest

    Hi,
    I would like to know how multi-threading works on a
    multi-processor machine(G4 power MAC).Do special commands have to be
    given access multiple processors?
    Thanks,
    Murali.
     
    murali, Sep 13, 2003
    #1
    1. Advertising

  2. murali

    Sean Burke Guest

    (murali) writes:

    > Hi,
    > I would like to know how multi-threading works on a
    > multi-processor machine(G4 power MAC).Do special commands have to be
    > given access multiple processors?
    > Thanks,
    > Murali.


    Depends what programming language your are using.
    Assuming java, use the Thread class to create a
    new thread. In C/C++/Objective-C, use pthreads.

    -SEan
     
    Sean Burke, Sep 14, 2003
    #2
    1. Advertising

  3. murali

    Danny Woods Guest

    (murali) writes:

    > Hi,
    > I would like to know how multi-threading works on a
    > multi-processor machine(G4 power MAC).Do special commands have to be
    > given access multiple processors?


    Generally, the Java VM will try to balance out the threads it has across
    the available processors. It won't split a single thread, so running a
    single-threaded Java application on a multi-processor machine is a bit of a
    waste of time (the background threads, like the finalizer and the garbage
    collector, don't make enough use of a processor's time to be called
    'effective use').

    From the programmers' perspective, all that needs to be done is ensure
    that you have enough threads in your system to make use of what's
    available. If you're trying to make optimal use of the available processing
    power, Runtime.availableProcessors() will let you know what you have to
    work with.

    Finally, threading issues can bite you on a multi-processor system, so your
    thread interaction must be *very* careful. Remember, now you have *true*
    concurrency, with instructions executing side-by-side on the different
    processors. Java's built in synchronization mechanisms will help here.

    Hope that helps,

    Danny.
     
    Danny Woods, Sep 14, 2003
    #3
  4. murali

    Roedy Green Guest

    On 14 Sep 2003 22:40:58 +0100, Danny Woods
    <> wrote or quoted :

    >Generally, the Java VM will try to balance out the threads it has across
    >the available processors.


    If you are using native threads, the VM has no say in such decisions,
    other than by the priority you set on each thread. Allocating to CPUs
    is the OS's problem. Further a thread does not need to stay allocated
    to the same CPU throughout its lifetime.

    A better approximation to reality is that every task ready to go in is
    a queue. As cpus become available, they take the top task and run
    with it. It works sort of like a barbershop.




    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Sep 15, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    38
    Views:
    1,319
    Dennis Lee Bieber
    Feb 15, 2005
  2. Replies:
    9
    Views:
    1,125
    Mark Space
    Dec 29, 2007
  3. Steven Woody
    Replies:
    0
    Views:
    474
    Steven Woody
    Jan 9, 2009
  4. Steven Woody
    Replies:
    0
    Views:
    488
    Steven Woody
    Jan 9, 2009
  5. akineko
    Replies:
    3
    Views:
    2,730
    Jesse Noller
    Jan 29, 2009
Loading...

Share This Page