• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get adavatage of multiple core hardware

 
Costa Lamona
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

1) If I have a sever with 5 Processors, how to ensure that JVM will take advantages of these processors?

2) Does a multi-core hard ware need another arrangement?

Is implementing Runnable Thread is enough or there is something I should do.

Thanks
 
Henry Wong
author
Marshal
Pie
Posts: 21437
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All modern JVMs are implemented to have the OS deal with threading issues. All modern OSes (that I know of) are implemented to have different threads on different processors cores, if available.

So, as long as you are using current stuff, you really don't have to do much. The JVM should place different threads on different processors -- hence, it should "take advantage" of multiple processors.

Henry
 
Ajay Saxena
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All modern JVMs are implemented to have the OS deal with threading issues


To add to Henry's comment, pre-Java 1.2 used Green threads(User space threads),for enabling multi-threaded application development on platforms (OSes) that didn't have native support for multi-threading.

So if you are using Java 1.1,then probably the JVM needs to be instructed/configured someway to leverage multiprocessing capabilities of a multi-core machine.

However,I've no idea how user space threads could be scheduled on different processors bypassing the OS ( assuming the OS lacks thread support)

Henry,would you like to throw some light on that?

[ August 27, 2008: Message edited by: Ajay Saxena ]
[ August 27, 2008: Message edited by: Ajay Saxena ]
 
Henry Wong
author
Marshal
Pie
Posts: 21437
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry,would you like to throw some light on that?


It's quite simple. User level threads are not seen by the OS. Hence, as far as the OS is concerned, you have a single threaded application, no matter how many threads the Java application has.

In terms of timing, Java 1.1 / 1.2 was around 1996 or 1997. So, you are really going back a ways. IOWs, while I really like the history lesson, let's make sure that the OP deems it relevent to the question first.

Henry
 
Ajay Saxena
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's quite simple. User level threads are not seen by the OS. Hence, as far as the OS is concerned, you have a single threaded application, no matter how many threads the Java application has.


So for multi-core machines running OSes lacking support for multithreading,concurrent programming would remain limited to multi-Processing only.
 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"All modern OSes (that I know of) are implemented to have different threads on different processors cores, if available."


Can't you have it either way with Solaris for instance ? i.e. specifically restrict to one core, though I can't claim to have played with it apparently there are advantages with each setup.

Its discussed here ...

http://mail-archives.apache.org/mod_mbox/lucene-java-user/200804.mbox/%3C480D1459.50908@teamware.com%3E
 
Henry Wong
author
Marshal
Pie
Posts: 21437
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ajay Saxena:


So for multi-core machines running OSes lacking support for multithreading,concurrent programming would remain limited to multi-Processing only.


OSes that lack support for multithreading generally isn't capable of using multiple cores, so... no. This is, of course, a moot argument, unless you want to try it out by installing an old DOS instance somewhere.

Under the green threads model. Threading is handled by the green threads library. The user level library will timeslice the threads to use the one processor that it is capable of supporting. To the OS, it doesn't see the threading. It sees one thread running on one processor -- it just happens to be a scheduler and running on this one thread on the one processor.

Henry
 
Henry Wong
author
Marshal
Pie
Posts: 21437
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chris Hurst:

Can't you have it either way with Solaris for instance ? i.e. specifically restrict to one core, though I can't claim to have played with it apparently there are advantages with each setup.


Yes. Certain old versions of Solaris supports both Kernal and User Level threads. But the argument still applies. The Kernal only sees the Kernal level threads -- it doesn't see the User level threads.

And this last part is still debateable. It can generally be argued that support of both kernal and user level threads is a *failed* experiment. Modern version of Solaris support Kernal level threads only as the default model. User level threads (LWPs) is only support for backward compatibility.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic