Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More multiprocessing questions



bsd5tu1 wrote:

Thanks for all the responses everyone. Quite helpful.

Here are some more questions I've thought of about using a
multi-procesing machine with Java:

1. When a thread gets assigned to a given processor, is it tied to that
processor until it's death, or does the Kernel and/or JVM have the
ability to re-assign the thread to the other processor while it's
active? For example, suppose I write a Java application with 10 threads,
and all of a sudden one of them starts throwing a ton of work to
something like the event dispatching thread. Assuming the EDT would be
tied to a processor, could the kernel or JVM switch some (or all) of the
other threads to the other processor while active.

On OS X threads are not bound to specific CPUs. I don't recall ever hearing about a system that does that (binding processes to CPUs yes, but not individual threads within a process). OS X does not bind processes to specific CPUs, either. Java threads are scheduled the same as "native" threads, so each Java thread is competing with every other thread in every other process for the available CPUs. This seems to do a good job of balancing the load between the CPUs.


2. Is there a relatively easy way to monitor which thread is on which
processor?

Not that I know of.

1. We're working on a Java project that makes extensive use of threads,
thread control, etc. We're using OS X, several Linux versions, and
numerous Windows variants for development and testing. Everything looks
good so far, but we haven't, at least to the best of my knowledge,
tested the product against machines using 2 (or more)
processors...probably because they cost so much. We also have tested
our products against machines with varying CPU speeds (for OS X, 400M
PPC up to the latest, FWIW, but it's all single processor, unless you
want to call the dual core Intels "dual processor"...and I really don't
know if that comparison is fair). The question is quite simple: Could
running the program on a dual (or quad) machine expose problems that
weren't transparent under a single processing machine, or does the JVM
see these mutliple processors as a single entity and control the threads
accordingly? THE MORE I THINK ABOUT THIS ISSUE, THE MORE IT FRIGHTENS ME!!!

As others have posted, a multi-CPU system can expose concurrency bugs in your code that cannot cause trouble on a single CPU/core system. If your users have them, you need to test with them, or else you'll only learn of such bugs when your users find them after your software ships. Given that Apple is making dual-core system so readily available, even if your currently user base is 100% single core/CPU it probably won't be for long. In order to write robust code for a multi-threaded environment (and Swing is necessarily a multi-threaded environment), you need to have a good understanding of concurrency issues, and "MT-safe" practices. A quick google turned up:


http://java.sun.com/docs/books/tutorial/essential/threads/index.html
http://java.sun.com/docs/books/tutorial/essential/threads/ multithreaded.html
http://www.deitel.com/articles/java_tutorials/20051126/ JavaMultithreading_Tutorial_Part1.html
http://java.about.com/od/threadprogramming/
http://www.ibm.com/developerworks/library/j-thread.html


The bulk of MT-safety boils down to dealing with read-modify-write cycles (typically by locking) -- pretty simple, but very pervasive.

2. With Apple making the move to Intel, how long will Java for PPC
machines, dual or single processor, even be supported? Since Java SEEMS
to be tied to OS releases, is there a detailed map of what will and
won't be supported in the future as well as a timeline? I've heard that
Apple's transition from 68000 based machines to PPC machines wasn't
exactly "friendly"....meaning that if you used an old 68000 based
machine within a year or two you were pretty much stuck with old
releases and updates, with your only option being to get a new machine.
This, of course, begs the question, is buying a PPC machine, regardless
of it's price, dual processor or not, even worth doing?

I had a Quadra back in the days of the PPC transition, and it wasn't that bad. IIRC the first PPCs ran OS 7.5.x, and Apple continued to support '040 Macs up to and including 8.1 (030 and older CPUs were dropped earlier). OS 8.5 was the first PPC-only release. I didn't feel I needed to upgrade to a PPC for a long time (I finally upgraded to a beige G3 in 1998), and it was a need for RAM that finally pushed me to it. Today's Apple is a bit different, though. In those days, Apple made many new technologies available in System 7 using extensions and enablers, in addition to delivering them in new releases. Going forward with a PPC (even a G5) will begin being constrained for adopting leading-edge technology once Apple stops releasing OS X updates for it. If being an early adopter of new software technology over the long term (4+ years) is important for this computer, then get an Intel -- it will handle leading-edge stuff for longer than a G5 will. If you are more focussed on shorter term (2-3 years) issues, then the G5 would be adequate. I'm grappling with this issue myself -- should I replace my aging G3 now with a G5, wait for a rev-B Intel "Mac Pro", or buy an Intel iMac as a short term solution (disclaimer: having spent the weekend coercing my G3 back to life after an electrical storm took out the HD I'm more than a little bit biased towards replacing it!)


3. I have to assume that PPC dual processor machines will be replaced by
Intel based equivalents. Is there a timeline for this anywhere?

The best you can do for timeline type info from Apple is WWDC (which is under NDA). I think that the most recent statements Apple has made in this regard are that the entire line will be on Intel by the end of 2006, and (a bit more recently) that the Intel transition was "ahead of schedule". The rumour mill is speculating that the "Mac Pro" (replacing the PowerMac G5) will be announced at WWDC in early August. The XServe has been expected to be the last system to transition to Intel, based on Intel's CPU availability roadmap. But this is all speculative.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.